2012年4月30日星期一

Community News: Latest PEAR Releases for 04.30.2012

Latest PEAR Releases:

MaltBlue.com: Zend Form Mastery with Zend Config - Part 1, Custom Filter Paths


From MaltBlue.com there's a new post (the first in a series) about mastering Zend_Form. In this first part of the series, they look at creating custom filter paths with the help of the Zend_Config component.



When you're working with Zend Framework, and code in general, you keep your configuration as much out of code as you can - right? Well, if you want to write maintainable and flexible code you do. Well, if you've been working with Zend Framework and Zend Form for more than a little while, you know that it really makes that pretty simple via Zend_Config - well, some of the time.


The article shows introduces you to some of the common configuration settings of Zend_Form and how those can be set in a configuration to make building the forms simpler. They talk about pre-element and form-wide filters in this first part of the series, including some code/configuration examples.

PHPMaster.com: REST - Can You do More than Spell It? Part 1


On the PHPMaster.com site there's a recent tutorial posted, the first part in a series of posts from David Shirey about building REST APIs in PHP. This first part of the series stays pretty high-level and really just introduces some common REST concepts.



Thousands of years ago when we first started building web pages, things were very simple. You'd put some text on the page, maybe even an image, and that was pretty much it. But today it's a whole different ball game. Instead of static pages there's the dynamic applications we've come to depend on. And so, how these applications are designed to communicate becomes very important. In this series I'll introduce you to the REST architecture style. In this article I'll help you to understand exactly what it is, and later I'll show you how it can be implemented in a PHP environment.


He defines the term "REST" for those not familiar and how a typical RESTful API allows other end users/software to interact directly with its data. He outlines some of the common principles of REST and finishes the post with a comparison of two HTTP verbs - PUT and POST.

ServerGrove Blog: Spooling emails with Symfony2 on VPS and Shared Hosting


The ServerGrove blog has a recent post for the Symfony2 users out there, showing how you can spool emails on a VPS/shared hosting using SwiftMailer and the Symfony2 bundle to interact with it.



When you send an email, the mailer communicates with a remote server in charge of receiving the message and of delivering it to the recipient. This process can cause your form to submit slowly as it depends on how fast the mail server responds. Spooling allows us to decouple the application execution line from the process of the sending one, two, or as many emails as we need.


They show you how to configure the SwiftMailerBundle with the mail server's settings, how to set up the command to send the emails and the settings you'll need to put in your cron file to run the "send" operation periodically.

Ibuildings techPortal: DPC Radio: The Art of the User Experience (Keynote, Aral Balkan)


The Ibuildings techPortal has published the latest episode of their DPCRadio series (as recorded at the Dutch PHP Conference 2011) - Aral Balkan's keynote session The Art of the User Experience: making beautiful, delightful, fun things.



In this session, Aral Balkan will outline the important role that user experience design plays in the making of virtual products and inspire you to see that it is your job - regardless of whether you make web sites, mobile apps, intranet systems, or ticket machines - to make this new world that we are crafting together not only usable and accessible but beautiful, fun, inspiring, pleasurable, delightful, and - dare I say - magical.


You can listen to this latest episode either via the in-page player, by downloading the mp3 or by subscribing to their feed.

2012年4月27日星期五

Site News: Popular Posts for the Week of 04.27.2012

Popular posts from PHPDeveloper.org for the past week:

Kevin Schroeder's Blog: ZF2 Dependency Injection: Managing Configuration - Part 2


Kevin Schroeder has posted the second part of his ZF2 dependency injection series (part one here) talking about their configuration.



In my previous post about Dependency Injection Container (DiC) configuration I made mention of some more complicated scenarios that you can use to configure your objects. Not that you need help to make it more complicated. [...] That's why I think this series of blog posts are good. They show you how to get started small which is really the only way to get started if you aren't intimately familiar with a DiC.


He expands on the previous example by adding another method that lets you set up some testing data (injected into the Test class object) and feed in the data via the "parameters" DI container configuration.

Evan Coury's Blog: Sharing a database connection across modules in Zend Framework 2


Evan Coury has a new post to his site about a handy method for sharing database connections across modules in a Zend Framework application.



With the new modular infrastructure in Zend Framework 2, one of the most common questions will indoubitably be how to share a database connection across modules. Here's a quick explanation of how to share your database connection across multiple modules in a way that can even allow you to use a single connection between ZendDb, Doctrine2, and possibly even other database libraries / ORMs.


He includes the code in the post to configure this application-wide database resource, a "masterdb_pdo" that uses a MySQL backend. This configuration is used to set up the connection in a dependency injection container for later (globalish) use. He also mentions something similar about sharing Doctrine connections with the ZendDb components (using the same DI container approach).

/Dev/Hell Podcast: Episode 11: From Gas Station Attendant to Java Developer


The /Dev/Hell podcast has released their latest episode (hosted by PHP community members Chris Hartjes and Ed Finkler) - Episode 11: "From Gas Station Attendant to Java Developer".



This time out we are blessed by the presence of Jo ël Perras, PHP developer extraordinaire and Fictive Kin brosef of Ed. We explore Jo ël's rags-to-riches story: a young academic schlepping coffee and 44oz soft drinks at a gas station, where he's discovered by a grizzled dev team manager in need of Java skills. From there it's been a whirlwind of web sites, programming languages, and more ops than you can shake a stick at. Actually I was sleepy and wasn't really listening for the first half-hour. I bet it's good though.


You can listen to this latest episode by grabbing the mp3 or by subscribing to their feed (either RSS or iTunes) and get this and other great episodes.

SitePoint.com: Sneak Peek at Kevin Yank's New Book 'PHP & MYSQL: Novice to Ninja'


SitePoint.com has published an excerpt from an upcoming book by their own Kevin Yank aimed at those wanting to get into PHP with no background in the language at all - "PHP & MySQL: Novice to Ninja".



Kevin Yank's done it again! He's just completed a new 2012 edition of his best-selling book (Build Your Own Database Driven Web Site, 4th Edition) which is now titled - PHP & MySQL: Novice to Ninja.


The chapter excerpt they share is the book's "Introducing PHP" content the (very) basic introduction to the language showing syntax and some of the benefits of the language. They also give you a preview of some of the other bits of content in the book including sections on database design, building a CMS, setting up shopping carts and getting PHP+MySQL installed on multiple platforms.

2012年4月26日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

PHP.net: PHP 5.3.11 And PHP 5.4.1 Released!


The PHP project has officially released the latest versions of the language - PHP 5.3.11 and PHP 5.4.1:



The PHP development team announces the immediate availability of PHP 5.3.11 and PHP 5.4.1. These releases focuses on improving the stability of the current PHP branches with over 60 bug fixes, some of which are security related. [...] For a full list of changes in PHP 5.3.11 and PHP 5.4.1, see the ChangeLog. For source downloads please visit our downloads page, Windows binaries can be found on windows.php.net/download/. All users of PHP are strongly encouraged to upgrade to PHP 5.3.11 or PHP 5.4.1.


Several bugs were fixed in both releases including issues with validation of the name of the uploaded file, adding open_basedir checks to readline_write_history/readline_read_history,
and the addition of debug info handler to DOM objects.

Kevin Schroeder's Blog: ZF2 Dependency Injection: Managing Configuration - Part 1


Kevin Schroeder has a new post talking about dependency injection in a Zend Framework v2-based application and managing your configurations.



In my previous blog post I showed how you could provide parameters to object that you're pulling from a DiC and have them populated in the resulting object. As cool as that is, it's not a massive saving as you need to manually inject the parameters into the DiC. You can often do the same thing by setting up the DiC ahead of time to get the object with those parameters pre-set.


He defines a class (Test) and shows how you can replace the DI container example with a ZendDiConfiguration object that contains the config options. He shows how to use this newly created container to access an instance of this "Test" class.

PHPMaster.com: An Intro to Virtual Proxies, Part 2


Following up on his previous article, Alejandro Gervasio has a new post to PHPMaster.com with the second part of his series on using virtual proxies in PHP.



Resting on the foundation of Polymorphism (dynamic Polymorphism, not the ad-hoc one often achieved through plain method overriding), Virtual Proxies are a simple yet solid concept which allows you to defer the construction/loading of expensive object graphs without having to modify client code.


He shows how to create a collection of domain objects that use proxies to populate their data. He includes the code for creating a "Post" interface/object as well as a Comment interface/object. These are put into a "CommentCollection" and, when it's accessed, pull the item in the collection out, only populating the data on demand.

DZone.com: Testing PHP scripts


In this new post to DZone.com, Giorgio Sironi talks about a method of testing that's non-invasive when you're in a chicken-and-egg kind of situation:



The legacy code dilemma, however, is always present: you can't refactor the code before putting up some tests on it to avoid regressions and putting your application offline. At the same time, you can't easily unit test the code until some refactoring is introduced.


He suggests making copies of some files to allow you to make small changes where needed to "mock" resources in the application to prevent it from accessing the actual data sources. His method fakes HTTP requests to the script and uses the copy of the script as an internal resource. Don't worry, code is included showing how its done - a basic "ForumPosting" class that includes the needed file and wraps the output in a buffer.

Seth May's Blog: The 5 Ws of Data Validation - Part 1


With a reminder about the best practice of always validating your data, Seth May has this new post about the "Five Ws" of validation - why, when, where and who.



As web developers, the applications you write are complex data processing engines. They try and convince your users to enter good, meaningful data and to respond in solid, predictable ways based on what was entered. Robust data validation will allow the rest of you application to work effectively. [...] Data is scrutinized in various ways to make sure that it adheres to basic restrictions and to fundamental properties. It's no good receiving a sandwich when you expect a car.

The questions he answers are:



  • Why is Data Validation Important?
  • Where Should I be Validating Data?
  • When Should My Data Be Validated?
  • Who is Responsible for Validation?
  • How Do I Validate My Data? (yes, there's a "w" in there!)


In the real world data is ugly, crazy, and untrustworthy. Your only hope to taming the data beast is to diligently, methodically validate your data.

2012年4月25日星期三

Community News: Latest Releases from PHPClasses.org

Shashikant Jagtap's Blog: Adding More Sauce To Behat


On his "Let's BDD" blog Shashikant Jagtap looks at the integration of Saucelabs and Behat for even more functionality when creating BDD tests.



On the occasion of Selenium Conference, I met with Noah Sussman talking about "Selenium In the Enterprise: What Went Right, What Went Wrong (So Far)" and one of his slides indicated that, team using Behat and Mink for the functional testing at Etsy. Noah then introduced me to Laura Beth who setup Behat/Mink and SauceLabs integration. Behat-Sauce configuration by Laura Beth is very easy to use. Now, we will see this in action.


Shashikant shows how to clone the github repository for the behat-suacelabs tool Etsy uses, use Composer to get all of the needed dependencies and a sample set of tests showing a sample set of Scenarios and their matching features (code). You can watch a video of the result here.

Jani Hartikainen's Blog: 5 ways how PHP is better than Node.js


In what's sure to be a "flame bait" kind of post, Jani Hartikainen has posted five reasons PHP is better than Node.js - some simple one-liners and others a bit more complicated.



All hail Node.js! Boo PHP! Except there are various things where PHP is better than Node…

His five reasons are:



  • Easier to find hosting
  • It's easier to get started with PHP
  • If your PHP code breaks, it doesn't bring your whole server down
  • PHP processes are short lived
  • Bigger standard library


There's a few comments on the post already, one noting that some of the points could be turned around to make PHP fall more on the "bad" side.

Danne Lundqvist's Blog: Getting to grips with an existing XML structure


Danne Lundqvist has a new post where he shares a bit of code he's written to "come to grips" with an existing XML structure.



Very often I find myself writing input filters for large XML files using PHP. Common enough task; and PHP offer a great variety of tools to do this effectively depending on the situation. Unfortunately, almost as common is the lack of documentation for the aforementioned XML files. [...] I have looked around for a simple tool but I didn't really find a tool that gave me the quick and dirty overview I wanted. A year or so ago I finally wrote a small PHP class to analyze large XML files.


He includes an example XML file, the HTML output of the parsing and a sample of how to use the class to parse and output the XML structure, complete with some CSS.

Ibuildings techPortal: Want a DPC Ticket? Just ask!


On the Ibuildings techPortal there's a new post for people out there wanting to attend this year's Dutch PHP Conference but find the ticket price a problem - they're running a contest to give away one ticket for this year's event!



Good news! We've managed to acquire a conference ticket for the Dutch PHP Conference in Amsterdam, on June 8th and 9th, to give away to our readers. We know that since you're reading techPortal, you are interested in technology in general and probably PHP in particular. The Dutch PHP Conference is one of the leading european conferences for PHP content and we hope you can join us there!


The ticket to this year's Conference also includes admittance into the Dutch Mobile Conference if you're interested in that as well. You can find out more about the Dutch PHP Conference on the main event site.

2012年4月24日星期二

Community News: Latest PECL Releases for 04.24.2012

Latest PECL Releases:

Kevin Schroeder's Blog: A little more advanced ZF2 EventManager usage


Kevin Schroeder has a new post to his his blog with a bit more advanced example of using the Zend Framework 2 EventManager to make global event triggers.



If you look at my previous post on the ZF2 EventManager class you might be tempted to think that you are limited only to listening to events for local instances of the event manager. But no, my friend, you would be wrong. The event manager actually provides access to a sort of global event manager. But it's more than that. This global event manager allows you to listen in on events for various targets.


He includes an example of how to use the EventManager in a specific namespace that's triggered based on a custom event. He attaches a custom class, "cls2", to a listener on his "ns1/cls1" class.

Refulz Blog: Yii Framework - Scenarios for Conditional Multiple Validation Rules


On the Refulz blog there's a post showing you how to set up conditional multiple validation rules in a Yii framework application.



I am yet to write the last article of the Yii Session series. I just decided to write something about the scenarios in the Validation feature of Yii framework. Scenarios are a very useful tool for adding different validations rules for different cases on the same model. In a real life situation, you would require one validation rule for user registration but the same rule might not be applicable to the User login. Scenarios help you define validation rules for different situations within same model.


He shows you how to set up a "rules()" method in your model and a few validation configurations inside it - ensuring the password and email are set, checking the length of the password, etc. Then, by calling the "validate()" method on the model, you can easily apply these rules and check the pass/fail status.

PHPMaster.com: Working with Files in PHP


On PHPMaster.com today there's a new tutorial that shows you some examples of working with files and the local file system in your PHP applications.



You may well be familiar with databases such as MySQL and Access which are an ever-increasingly common means of storing data. But data is also stored in files, like Word documents, event logs, spreadsheets, image files, and so on. Databases generally require a special query language to retrieve information, whereas files are 'flat' and usually appear as a stream of text. [...] PHP provides a range of functions which allow you to work with files, and in this article I'll demonstrate some of them for you.


Examples in the article include the use of several of the PHP file functions including: filesize, filectime, is_readable, file_put_contents and fopen. There's also an example of using the CSV file functions for working with a comma-separated file (both in reading and writing).

2012年4月23日星期一

Community News: Latest PEAR Releases for 04.23.2012

Latest PEAR Releases:

7php.com: Interview with Davey Shafik, The Original Author of Phar


On the 7php.com blog today they've posted the latest in their series of PHP community interviews - a few questions with Davey Shafik, the original author of phar.



In this edition I talked with Davey Shafik (@dshafik), who is one of the Founding Contributor of PHP Zend Framework. He has been a co-author of several prominent books, namely: php|architect's PHP 5 Zend Certification Study Guide, PHP Master: Write Cutting Edge Code, The PHP Anthology: 101 Essential Tips, Tricks & Hacks. He is also a well-known speaker at several world-wide PHP Conferences - You can find his incoming conference schedules on his website.


In his answers we find out about:



  • Where he feels his place is in the PHP community
  • What he's excited about in PHP 5.4
  • Some advice to beginners about "scratching an itch"
  • Recommendations about profiling your code
  • Resources he suggests
  • His admiration of Sebastian Bergmann for the hard work he does


You can read more about these and the rest of his answers in the full interview.

Community News: ZendCon 2012 Call for Papers Open!


The Call for Papers for this year's ZendCon Conference have officially opened! This year's event will be once again in Santa Clara, CA and will be from October 22nd through the 25th.



We are happy to announce that planning is underway for the 2012 Zend PHP Conference, to be held in Santa Clara, October 22-25, 2012. ZendCon 2012 will be the best conference yet and we would like to invite you to be a part of it! A conference is only as good as its speakers and we are looking for the best speakers to share their knowledge and expertise with the PHP community. Attendees will include developers, architects, development managers, decision makers, core PHP developers and community members.


Key themes they're looking for in this year's conference are "PHP in 2012", "Zend Framework 2" and "Development & The Cloud" as well as other topics including:



  • Framework-based development
  • Server and cloud-based infrastructure
  • Databases, storage and data modeling
  • Unsung Tools
  • Agile processes and project management


The Call for Papers for this year's event ends May 21st, so be sure and get your submissions in soon!

Rob Allen's Blog: An introduction to ZendEventManager


Rob Allen has a new post to his blog today introducing you to the ZendEventManager component of the Zend Framework v2, a key part of how this latest version of the framework does its job.



Zend Framework 2's EventManager is a key component of the framework which is used for the core MVC system. The EventManager allows a class to publish events that other objects can listen for and then act when the event occurs. The convention within Zend Framework 2 is that any class that triggers events composing its own EventManager.


He starts with some terminology to get everyone on the same page (listener, event, EventManager) and includes an example of its use in setting up a "PhotoMapper" object showing how to trigger events in the "findById" method. He shows how to listen for a specific event (in his case, a "pre-execute" on the "findById" method) and a method for "short circuiting" the listener based on the response from the "trigger" call. He also touches on the "SharedEventManager" that can be used to add an event across all of your application at the same time.

Wojciech Sznapka's Blog: Deploying Symfony2 applications with Ant


In this new post Wojciech Sznapka shows you how to can set up an Apache Ant deployment for a basic Symfony2 application - including installation of vendor packages and assets.



When you have plenty of Symfony2 applications and you need to deploy them from time to time, you are probably sick of thinking about every activity you need to do for every deploy. Often people use some build scripts, which are hard to maintain and tends to be unreadable. I wanted to automate it as much as it possible and I've choosen Ant, to help me out.


An example build.xml file is included in the post that shows how to:



  • Pull the current code from git
  • Install vendor packages
  • Fix permissions for the log and cache directories
  • Clean up the cache
  • Dump/install any additional assets

2012年4月20日星期五

Site News: Popular Posts for the Week of 04.20.2012

Popular posts from PHPDeveloper.org for the past week:

Nodeable Blog: Marten Mickos: The LAMP Stack is Dead, and Cloud has Killed It


In this recent post to the Nodeable Blog, they suggest that the days of the typical LAMP stack (Linux, Apache, MySQL, PHP) are numbered because of what many of the cloud services have to offer.



For the past 10 years, the LAMP stack has laid waste to proprietary software stacks. Yes, Microsoft has held onto gargantuan profits, but LAMP has become the foundation for leading web services, whether Google or Facebook or [Insert Big Web Brand Here]. LAMP is the future. Or was. That is, until cloud killed it, as Eucalyptus CEO (and former MySQL CEO) Marten Mickos posits in a great keynote from the Percona Live: MySQL Conference & Expo 2012.


In the keynote he pointed out that it's becoming less about the whole setup and more about combining technologies to get the results you need - less "stack" and more "linked technology" (and not always the same tech for every node). He pointed to the Amazon AWS service as a prime example of a platform that allows endless flexibility as to what software can be installed and how it can be used, all with a few clicks of a mouse.

Gaurish Patil's Blog: URL rewriting in Yii to hide index.php


In this new post to his blog Gaurish Patil shows users of the Yii framework how they can update their configuration settings to hide the "index.php" in their requests and make cleaner URLs.



Finally we figure out the basics of Yii. While working on basic of Yii, I want to rewrite the url to SEO friendly. So I started to search on google, forum got useful information here http://www.yiiframework.com/doc/guide/1.1/en/topics.url To hide the index.php from url I did changes in config/main.php [...] and I created new .htaccess file in the same directory as my index.php file.


The changes are pretty simple - it's mostly a change to the "urlManager" setting to provide some rules for mapping controller and actions to the right place. The .htaccess file uses Apache's mod_rewrite functionality to grab the requested URL and remap it back to lay on top of the "index.php" front controller for the request.

Shashikant Jagtap's Blog: PHPUnit + Behat/Mink + Page Object: The Rockstar Combination of Testing


Earlier this month Shashikant Jagtap wrote up a post about a powerful combination in testing your applications - a "rockstar" combo of PHPUnit + Behat/Mink + Page Object to give you a great foundation for BDD (behavior-driven) testing.



Last month, we had discussion about implementing page object pattern in Behat/Mink framework at London Behat Users meetup. Page object pattern is a cool way to make tests maintainable, reusable and readable. Everyone was interested to know more about Page Object Pattern. In this short tutorial, we will implement Mink and PHPUnit combination for functional testing. Mink and PHPUnit combined with Pageness (Page Object) can be used for maintainable and readable tests.


He assumes that you might not have all the tools needed installed, so he walks you through the setup/install of PHPUnit, the PHPUnit-Mink framework and both the Sahi and Selenium drivers. He includes a basic directory structure for the testing and shows how to create some Page Object classes that extend the default TestCase and make calling the remote resource simple. He also includes the steps needed to execute the tests via PHPUnit.

Community News: OSCON 2012 Schedule Announced (with PHP Track)


The schedule for this year's OSCON conference has officially been announced and there's several PHP sessions on the schedule this year including:




There's lots more on the list too, so check out the full list for the PHP track at this year's event! OSCON is being held July 16-20th in Portland, Oregon. For more information on tickets see this page on the conference site.

2012年4月19日星期四

PHPMaster.com: An Intro to Virtual Proxies, Part 1


On PHPMaster.com today there's a new tutorial from Alejandro Gervasio about using virtual proxies in your application - a method in development that provides a layer of abstraction on top of domain objects and makes it more efficient to work with (and lazy load) them.



Often referenced by a few other fancy names, the substitute is generically called a virtual proxy, a sort of stand-in that exploits the neatness of Polymorphism and interacts with the actual domain objects. Proxies aren't new to PHP. Doctrine and Zend Framework 2.x make use of them, although with different aims. On behalf of a didactic cause, however, it would be pretty instructive to implement some custom proxy classes and use them for lazy-loading a few basic aggregates from the database, this way illustrating how virtual proxies do their stuff under the hood.


He starts off by setting up a domain model for a "Post" and "Author" - a typical blog example.Based on the definition of these classes, he creates a mapper class to generate Author objects and an "AuthorProxy" class that uses a "loadAuthor" method to only load in the author's details when a property is requested. He gives a bit more code showing it in action and the difference between using the normal Author and AuthorProxy class.

ServerGrove Blog: How to Create a Cache Warmer in Symfony2


In this new post from the ServerGrove blog Ismael Ambrosi shows how to create a "cache warmer" for a Symfony2 application - a handy tool that can pre-populate your applications cache with data you specify before it's needed by the app.



The cache is a very important part of your Symfony application as it helps your web server to perform better by not executing unnecessary code on every request, this is especially true if your server is running with limited resources. Cache warming allows you to cache specific data in your application through the use of a CacheWarmer. Symfony 2 includes a cache warmer that helps you to store parts of your application in cache, before the application becomes available to the user.


He shows how to create the "warmup" in an object extending the CacheWarmer to pull in content (in his case, just a text string) and write it out to a cache file automatically. Also included is the config updates you'll need to make to tell the Service Container about the Warmer.

Lee Davis' Blog: Zend Paginator Example


In a recent post to his blog Lee Davis gives an example of using the Zend Framework's pagination functionality, complete with some CSS to style it a bit better than the defaults.



One of the reasons why zend framework has been so popular is due to all the hard work put in to make sure components are extremely configurable. Sure there are default behaviours, but nothing is assumed and anything that needs to be overwritten or reconfigured can be. A strong emphasis on configuration over convention means you'll never be lumbered with code that just can't be changed. Zend Paginator is one of the smaller components of Zend Framework that allows you to get a simple
paginator up and running on your listings or search pages in a matter of minutes.


Included in the post is a cut-and-pasteable view that creates the Previous/Next links as well as including the first/last page numbers and a few around the current page.

2012年4月18日星期三

Community News: Latest Releases from PHPClasses.org

Voices of the ElePHPant Podcast: Interview with Harrie Verveer


On the Voices of the ElePHPant podcast site, they've posted the latest episode - an interview with Harrie Verveer, an organizer for the Dutch PHP Conference and an employee of Ibuildings.



Cal's "three questions" during the interview relate to



  • What pushed you into wanting to speak at a user group?
  • As a speaker, what advice do you have for people wanting to get started at user groups or conferences?
  • As an organizer, has your perspective on speaking changed? What advice do you have for people to get to the conference level?


You can listen to this latest episode either by using the in-page player, by downloading the mp3 or subscribing to their feed.

Anthony Ferrara's Blog: Properly Salting Passwords, The Case Against Pepper


In this new post to his blog Anthony Ferrara looks at a common idea that comes up when the discussion of encryption of passwords in PHP - the global salt (or "pepper").



The other day I announced the release of my new password hashing library, PasswordLib. As I've come to expect, Reddit was full of interesting commentary on the topic. Some was good, some was bad and some surprised me. What surprised me was the insistence on a global salt (otherwise known as a "pepper"). So, I started thinking about it some more, and I figured I'd write a post on why I don't use peppers in my hashing algorithms (and why you may want to rethink it too).


He starts with an explanation of what a salt is (and isn't) to lead naturally into the idea of a "pepper", a single unique value that's used across an entire site/application for password encryption. He covers four flaws inherent with this method:



  • There's no proof that using them increases your security.
  • There are no publicly vetted hashing algorithms that accept a pepper as an argument.
  • Using a block cipher instead of a pepper provides a stronger level of encryption and protection.
  • The entire concept of a pepper is based around a flawed premise. [...] The flaw in that premise is that it's often not just your database that's leaked.

Brandon Savage's Blog: Book Review: The Grumpy Programmer's Guide To Building Testable Applications


On his blog Brandon Savage has a new post reviewing a book from Chris Hartjes, "The Grumpy Programmer's Guide To Building Testable Applications".



When most developers think about books on testing, they think about books that highlight things like "test driven development" or "how to build a test for X." [...] This is not true of Chris Hartjes' book, "The Grumpy Programmer's Guide To Building Testable PHP Applications". When I asked Chris if I could review his book, I expected a step-by-step guide to writing tests. What I got was a step-by-step guide to building an application that COULD be tested. There's a big difference, and it's important to understand the distinction.


He points out that the book provides more about good application structure than who to write the tests for it. It provides a guide to creating modular applications that can be easily pulled apart and tested as well as some practical examples. He also includes a few "wise words" quoted from the book including: "if it's not yours, wrap it up" and "testing is good; testable applications are better."



You can pick up your own copy of the book fron its page on the Leanpub site.

2012年4月17日星期二

Community News: Latest PECL Releases for 04.17.2012

Latest PECL Releases:

Community News: Atlanta PHP May Meetup - PyroCMS from John Corry (May 3rd @ 7pm)


The Atlanta PHP User Group has announced their May 2012 meeting on their site today. In next month's meeting John Corry will be presenting about PyroCMS and why you should base your next site on it.



If you use (or would like to use) the CodeIgniter framework in your PHP projects, you've probably seen that each project requires common elements (authentication, user management, basic CMS components). Take a walkthrough of PyroCMS with John Corry to learn how you can leverage it's components to bring your projects closer to completion right out of the box! If you love CI, you'll LOVE PyroCMS!


The meeting will be May 3rd from 7-9pm at Strongbox West there in Atlanta. If you have a user group meeting you'd like announced, send the information on over and it'll get posted!

PHPMaster.com: Maintaining your Server with Command Line PHP


Stephen Thorpe has a new article posted on the PHPMaster.com site today about using command line PHP to handle some of the automation on your server.



n this article we'll look at the advantages of using PHP CLI. I'll show you how to test PHP's Command Line Interface / Interpreter (CLI) on your server, and then we'll look at some of the options available for PHP CLI including the interactive shell and how to create executable scripts. Finally, I'll give you a couple of examples of scripts to use to maintain your server written in PHP.


He introduces the command-line executable for PHP and shows how to use it to create some simple scripts (including ones that take in command-line arguments). He shows how to make a simple script to monitor disk usage (using the unix command "df") and a backup script that copies files/folders over to another device.

DZone.com: The standard PHP setup


On DZone.com Giorgio Sironi shares what he describes as his "standard PHP setup" - the tools and standards he commonly uses when developing his projects.



Last week I passed a day speeding up a Java and Ruby oriented team which started developing a PHP application: not only a standard project structure was required, but also some hints on the default tools and process to work with it. Here's what I thought was crucial during the setup, based on the question of my Rubyist colleague. Of course one of the most visible differences is the language itself, but there is a lot more tacit knowledge to share.


Things mentioned in the post include: development tools (like IDEs), the language itself and similarities to other languages, a standardized project setup, a good testing methodology and a bit of discussion about using external libraries.

Code2Learn.com: Using HighCharts with php , MySQL and CodeIgniter


New on the Code2Learn site there's a tutorial showing how to integrate HighCharts, PHP, MySQL and CodeIgniter to create a simple graph based on database data.



While working on a project I found out that HighCharts is the best to display graphs on webpage as it has less overhead and requires less space. But the biggest challenge was to implement it using php and not jQuery. We will implement it using MVC pattern as CodeIgniter follows the same.


Included in the post is a library for interacting with HighCharts from PHP, configuration settings for CodeIgniter and the model/view/controller pieces to tie it all together. You can see an example of the end result here.

2012年4月16日星期一

Community News: Latest PEAR Releases for 04.16.2012

Latest PEAR Releases:

PHPMaster.com: Giving Your First PHP Presentation


In this recent post from PHPMaster.com Aaron Saray gives a few helpful hints (and reasons to speak) for the aspiring presenters out there wanting to give their first talk at a PHP (or any technology-related) conference.



Your heart begins to race. Suddenly, it's stifling hot in here. Your palms begin to sweat and your knees are threatening to give up and flee to a vacation in Cancun without you. The dull rhythmic thump-thump in your ears heightens to a frenzied jack-hammer. You can't remember a time when your mouth has been this dry. It's time to begin - and your voice cracks. It's public speaking time and you're the next one up. In this article I'll cover the basics of why presenting PHP is important, who can present about PHP related topics and what you can do to make your presentation stand out.


He starts off by answering the "why" question - why even give a presentation at a conference or local user group? His answer has a few parts and involves things like giving back to the community and being considered an expert in the field. He follows this with a few ways to help your talk stand out - include code samples, give live demos and be entertaining.

Rafael Dohms' Blog: Deploying a Symfony2 and Composer app on PagodaBox


Rafael Dohms has a new post sharing the results of one of his recent struggles - getting a Symfony2 application deployed to the PagodaBox service using Composer to manage the packages. In the post he details each step of the process.



I have been working on a little pet project and wanted to put it up somewhere to show to a few people how it was going. I wanted something really simple so I decided to give the PHP PaaS solutions a try. Its a very simple Symfony 2.1 based app using Composer for vendor management, so I went on a quest to see what could be done and how.


He shares the contents of his Boxfile (a special file PagodaBox uses to configure your application) with entries for writeable directories, extensions to load and the database configuration. He found that, during deployment, everything is writeable by the "build" user, so there's no worries about installing Composer dependencies.

Chris Hartjes' Blog: Build PHP 5.4 on CentOS With Vagrant


In a new post to his blog Chris Hartjes shows you how to get PHP 5.4 installed on a CentOS machine (virtual machine) with the help of Vagrant.



I like the idea of using
Vagrant to create virtual machines for my development work. Doing things this way I think keeps the host machine cleaner and allows you the ability to distribute those VM's to other people as well. My old boss Ben Ramsey did a very informative post on getting PHP 5.4 configured on CentOS so I decided to one-up him by taking his instructions and creating a Puppet manifest so you could do this using Vagrant or on any server that you can provision using Puppet.


He example is based off of the publiclly available Vagrant setup and provides the contents of the Vagrantfile that he uses to set up the machine. From there, Puppet takes over and uses his configuration (also included) to set up things like the Apache server, some configurations for it, a list of PHP extensions and, of course, PHP itself.

2012年4月13日星期五

Site News: Popular Posts for the Week of 04.13.2012

Popular posts from PHPDeveloper.org for the past week:

php|architect: Win a free ticket to tek '12!


php|architect has announced a new contest they'll be hosting (a scavenger hunt, really) and are giving away a ticket to this year's php|tek conference happening in May in Chicago.



Ok PHP fans, we don't do this often, but once a year we do give away a ticket to php|tek to one lucky programmer. This year, however, you are going to have to work for it. Starting Friday, April 13th, 2012, those of us who work at php|architect will tweet clues, and you are going on a web scavenger hunt. That's right, dig up other people's websites, trash their JavaScript and generally make a nuisance of yourself as you follow the clues to the…well, you'll just have to wait and see.


You'll need to follow the php|architect folks on Twiiter (Elizabeth Tucker, Marco Tabini and Cal Evans) to get clues about the hunt. First prize is a ticket to php|tek this year but other prizes include a ticket to their next Virtual Summit, any three books from their catalog and a free one-year subscription to the magazine.



Once you've found the solution, you'll need to enter it here to be entered. Good luck!

Pádraic Brady's Blog: PHP: Innocent Villagefolk or a Pillagin' Pirate?


In a new post to his blog Pádraic Brady wonders if PHP should be more equated to innocent villagefolk or a pillagin' pirate:



What PHP excels at is tireless consumption. Marathon races make one hungry and we can't help but notice the feasts being exposed by Rubyland or Pythonville as they do their best to sprint past us. Without that thieving spirit, PHP would long since have entered obscurity as a quaint HTML oriented scripting language used by college students to build cheap websites with flashing text and under construction GIFs. [...] Our strength lies in our ability to connect the dots several hundred times over to the point where the best dot connector gains a critical mass of adoption.


He talks about how most PHP developers seem to like doing things the hard way - reinventing the wheel, overstate personal preferences to the point of argument, ignoring best practices and promoting the bad ones.



He even suggests a possible new creed for PHP developers:



What we really need is a new PHP motto. Something deep and meaningful that exposes PHP's true nature. I was thinking "Rob 'em blind, matie!" would be a good one but I remembered that we need to cater for the Enterprise audience. Suggestions welcome.

Engine Yard: Cloud Out Loud Podcast - Future of PHP


Engine Yard has released the audio from a recent (webcast) panel discussion they did about the Future of PHP with members of the PHP community (a part of their "Cloud Out Loud" podcast series).



Elizabeth Naramore talks with David Soria Parra, Rasmus Lerdorf, and Stas Malyshev for a panel discussion about Internals. Our panel of experts will share their thoughts and predictions about the existing PHP landscape, and what is to come.


It's about 30 minutes long and they talk about PHP 5.4, compiling PHP, performance issues, the slow rate of adoption in newer releases, memory usage and some of the general strengths and weaknesses of the language. Elizabeth also asks each person on the panel about things they've each seen done wrong on the project and something they'd like to see in its future.



You can listen to this latest episode either via the in-page player or by downloading the mp3 directly.

2012年4月12日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

PHPMaster.com: Deploy and Release your Applications with Phing


In this new post to the PHPMaster.com site today Vito Tardia introduces you to Phing, a tool for making builds and deploying your applications (and it's PHP based!)



Suppose you have a web application that is installed on many hosts. Each installation may have a custom configuration, and the application is still in active development. You need an easy way to deploy new features and bug fixes to all of hosts. [...] In this article I show you how to use this knowledge [from this previous article] to write a boilerplate build file, one that can be customized and reused in your real-world applications. We'll use Phing's Subversion tasks to manage the repository and the FileSync extension to synchronize your local installation with a remote server.


He helps you to get the environment set up correctly (installing the needed PEAR packages), create a basic build file with the FTP settings in it and creating a "deploy" target to do the work. He also shows the settings/configuration involved in a "prepare" target that does the SVN work to do some of the pre-push work. Finally, he shows a "release" target that bundles up the files into a package and pushes it up to the server (via FTP).

Oracle Technology Network: New Features in PHP 5.4


On the Oracle Technology Network today there's a new article from Rasmus Lerdorf about the current release of the language (PHP 5.4) and what he sees as the future for PHP.



Almost exactly eight years ago I wrote an article for the Oracle Technology Network called, "Do You PHP?". In that article, I talked about PHP's stubborn, function-over-form approach to solving the "Web problem" and the fight to keep things simple. We were getting close to releasing PHP 5.0 at the time. Now here we are almost a decade later with a shiny new PHP 5.4.0 release, and while much has happened during that time, there are also many things that haven't changed at all.


The first talks about what's the same - the ecosystem surrounding the language and the strength of the LAMP stack that PHP helped to "found". He mentions some of the up-and-comers that are alternatives to this traditional setup and some of the extensions that have been added to improve PHP's functionality (DateTime, PDO, JSON support). He talks about other improvements in the language including:



  • Better memory management
  • Traits
  • Short Array Syntax
  • Closure binding
  • Built-in webserver
  • Native session handler interface
  • Removal of register_globals, magic_quotes and safe_mode


He briefly looks ahead at "what's next" for the language and points to the "internals" mailing list and the PHP wiki

phpDay Blog: Interview with Stefan Koopmanschap


In this new post to the phpDay blog, there's an interview with Stefan Koopmanschap, a speaker at this year's event.



This is the second 'social' interview in a series with the phpDay 2012 speakers: it's 'social' because the questions have been submitted and voted online on Facebook. We are happy to introduce you Stefan Koopmanschap (@skoop), co-founder of PHPBenelux, now active in the PFZ.nl events team , symfony community manager. He will give a session at phpDay called "A Practical Look At Symfony2" Saturday May 19th at 12 am on track 1.


They talk about Stefan's framework choice process, his thoughts on functional programming, what he thinks of traits in PHP 5.4 and what Open Source projects he's following the closest.



You can find out more about Stefan's session and the conference at http://2012.phpday.it.

Community News: CodeIgniter London Meetup (April 30th @ 8pm)


As mentioned by Phil Sturgeon, the London Codeigniter Meetup has come back and will be meeting at the end of this month (April 30th).


This month, since it's their first meeting, it's just a "networking" type of event:



Meeting in a pub, talking about our experience with CI, development in general, and networking.


The meeting is happening in London at 8pm on Monday, April 30th. For more information, check out this event over on Meetup.com.

2012年4月11日星期三

Community News: Latest Releases from PHPClasses.org

Juan Treminio's Blog: Getting Started with Kohana 3 (series)


Juan Treminio has started up series of posts over on his blog looking at the Kohana framework and guiding you through the creation of a sample application with it (in-depth).



The Kohana Framework started off as a fork of the very popular CodeIgniter Framework. During the KO 2.x versions, it stayed fairly similar to how CodeIgniter functioned, and a developer could easily jump from one to the other and feel very familiar. With the introduction of the Kohana 3.x version, this all changed, as Kohana was completely rewritten from the ground up. Now, unless you're a seasoned PHP developer, you may have difficulty making the jump from other frameworks in Kohana. I have written this tutorial to be your step-by-step guide into the world of Kohana

So far, he's posted three parts of the series:




Keep an eye on his blog for more posts in this great series!

BinaryTides.com: 40+ Techniques to enhance your php code (3 Part Series)


On the BinaryTides blog there's a series of posts that share some tips and suggestions aimed at helping you and your code be the best they can be - things to enhance your application (including suggestions not just about code but also about environment and development practices).



The three posts in the series include tips like:



  • Maintain debugging environment in your application
  • Collect all output at one place , and output at one shot to the browser
  • Set the correct character encoding for a mysql connection
  • Do not gzip output in your application , make apache do that
  • Don't check submit button value to check form submission
  • Process arrays quickly with array_map
  • Avoid direct SQL query , abstract it
  • Never set error_reporting to 0
  • Make a portable function for executing shell commands


Obviously, not all of these will apply in all situations, but they're an interesting list. Most will come with good explanations and code samples when appropriate.

Symfony Blog: Symfony Live Paris 2012: The Schedule


In this new post to the Symfony blog Fabien Potencier talks about the schedule for this year's Symfony Live event happening in Paris (June 6th-9th).



With more than 130 talk submissions, we had a hard time putting together what we think is a great schedule for Symfony Live Paris 2012. This year, we will have three parallel tracks with many great talks and great speakers. We will have many Symfony talks based on real-life experience: learn new tricks about Security and Assetic from Kris Wallsmith, and let Richard Miller teach you tips on how to use the Service Container.


Sessions at this year's event include:



  • Designing HTTP Interfaces and RESTful Web (David Zuelke)
  • Behat by example (Behat best practices) (Konstantin Kudryashov)
  • Security: In Real Life (Kris Wallsmith)
  • How we built the new responsive BBC News site (John Cleveley)
  • There is a Bundle for that (Christophe Coevoet)
  • Advanced Silex (Igor Wiedler)


If you want to attend this year's event, you can find more information here.

2012年4月10日星期二

Community News: Latest PECL Releases for 04.10.2012

Latest PECL Releases:

PHPMaster.com: Bulletproofing Database Interactions with PHPUnit's Database Extension


On PHPMaster.com today there's a new tutorial showing you how to test your application's interface with the database using "bulletproof" PHPUnit testing.



There's already a great article here that discusses Test Driven Development, but did you know that you can also test the code that interacts with your database? Especially if your application is data intensive, subjecting your CRUD code to a battery of tests is good practice that helps ensure that your application is working correctly. In this article you will be learning how to write database tests in PHP using PHPUnit and its database extension.


Included in the post is an example schema and an example of the seed data (defined as XML) for the testing to use as predictable data in its execution. His test class extends PHPUnit_Extensions_Database_TestCase (instead of the usual PHPUnit_Framework_TestCase) and a test for a basic "getArticles" method in his "IArticleDAO" class. By calling the "createXMLDataSet" method, the test loads in the pre-defined XML records and allows the correct evaluation of the assertions,

DZone.com: The Page Object pattern


On DZone.com today there's a new tutorial from Giorgia Sironi giving an example of working with the PageObject pattern and how it's implemented to help with testing in the PHPUnit_Selenium plugin.



In the realm of acceptance testing, a possibility for hooking into the application and exercising it end-to-end is to work through a user interface, which nowadays is in more and more cases web-based. The Page Object pattern is a way to model pages (intended as screens) of a web application as independent objects, and give them several responsibilities.


The pattern sets up the resources to let you make queries against the page's contents, interacting with elements on the page, running common assertions on the contents and moving around on the site. He gives a more practical example of it in action (again, using PHPUnit_Selenium) to test a login page and evaluate a successful login.

Gonzalo Ayuso's Blog: Inject dependencies via PhpDoc


Gonzalo Ayuso has a new post to his blog looking at a method for injecting dependencies into your application's code based on comments in the PHPDocumentor-formatted comments of your methods.



Last month I attended to Codemotion conference. I was listening to a talk about Java and I saw the "@inject" decorator. I must admit I switched off my mind from the conference and I started to take notes in my notebook. The idea is to implement something similar in PHP. It's a pity we don't have real decorators in PHP. I really miss them. We need to use PhpDoc. It's not the same than real decorators in other programming languages. That's my prototype. Let's go.


All of the code you'll need to recreate his solution is included - a sample "User" class that needs a valid PDO object in a private "db" property, a "DocInject" class that parses the comments and, using a new feature of PHP 5.4 (traits), injects the needed functionality into the "User" class and creates/assigns the object.



You can see just the full code in these two gists on Github.

2012年4月9日星期一

Community News: Latest PEAR Releases for 04.09.2012

Latest PEAR Releases:

PHPMaster.com: 6 Extra Skills Every PHP Developer Should Have


On PHPMaster.com today there's a new article with six things that they (well, Daniela Baker) thinks every independent PHP developer should know and have in their arsenal.



PHP development is hot right now, but there are also lots of people in PHP development. If you want to make it as an independent PHP developer you've got to know more than just PHP. Here are six other essential skills you need to succeed as a PHP developer.

Her list of six is made up of:



  • JavaScript, HTML, and CSS
  • Knowing What You Don't Know
  • Business Communication
  • Business Finance
  • Project Management
  • Networking


Really, independent or not, these types of skills/knowledge can help any developer out there to see the bigger picture outside of just their code, out to what the business is doing.

Sameer Borate's Blog: PHP 5.4.0 in a nutshell


If you've been looking for the "quick and dirty" definition of all of the changes that come with the latest version of PHP 5.4, you should check out this new post from Sameer Borate. It has a quick rundown, code included, of these new features and changes.



Although purists have always sneered upon PHP for being a "patched" language; the evolution of PHP over the years, with new features added in every version, has only increased its popularity. The latest 5.4 release has followed the trend with some major feature additions. The following post describes some important changes in PHP 5.4.


His list includes: the updated array syntax, the bulit-in web server, array dereferencing, traits, upload progress tracking and various core changes to things like the short syntax for calling static methods in classes and the complete remval of magic quotes.

7php.com: Interview with Chris Cornutt, The Hero Behind PHPdeveloper.org


On the 7php.com site today they've posted their latest interview with a member of the PHP community - Chris Cornutt (disclaimer: yep, that's me), the author/editor behind PHPDeveloper.org.



In this edition I talked with Chris Cornutt, the Hero Behind PHPdeveloper.org. If you are a PHP fan and you haven't heard about @phpdeveloper and @enygma, it's just like you are a manga fan without having ever heard of Goldorak (Grendizer in english) and Actarus (Duke Fleed in english)! If this is the case, you should start asking questions about the depth of your "PHP fan-ism". Apart from being a passionate PHP Community knight, Chris has an outstanding dedication for his endeavour over at PHPdeveloper.org. You will get to know about how 'mana-intensive' the 'upkeep' of this type of "Goldorak" is, as you read through the interview.

In the interview, some of the topics covered are:



  • Current and first projects
  • advice to budding PHP developers
  • framework recommendations
  • good and bad experiences at conferences
  • more details about the processes and work on the PHPDeveloper.org site


You can read more about these answers and others in the full interview!

Joshua Thijssen's Blog: Bloom Filters


In this new post to his blog Joshua Thijssen describes something that can help when processing large amounts of data (like, in his example, the text of a book) to search through the information and find if a certain piece of data is in the set - a bloom filter.



Most of my co-workers never really heard of bloom filters, and I'm continuously need to explain what they are, what their purpose is and why it's a better solution than other ones. So let's do an introduction on bloom filters. [...] Bloom filters have the property of being exceptionally fast AND exceptionally small compared to other structures but it comes with a price: it MIGHT be possible that our bloom filter thinks that an element is inside our set, when it really isn't. Luckily, the reverse is not possible: when a bloom filter says something is NOT in the set, you are 100% sure that it isn't part of the set.


He explains how the filter works, noting how it's better for memory consumption and how it's possible for it to give a "maybe" response instead of ab absolute "yes" or "no". He also points out a PHP extension, bloomy that takes the hard work out of it for you.

2012年4月6日星期五

Site News: Popular Posts for the Week of 04.06.2012

Popular posts from PHPDeveloper.org for the past week:

Chris Hartjes' Blog: Metatesting: Testing Constructors


In a new post to his blog Chris Hartjes, promoter of all things testing, looks a a method for testing constructors - an effective way to validate the things that happen when your objects are generated.



If you have a PHP application that makes heavy use of objects (which is probably 95% of you reading this) then you will have objects with constructor methods in them. It is also very likely that there is some stuff going on in those constructors. So how do you test things like this?


He includes a sample constructor that creates a container, pulls out some configuration values and reassigns them to class properties. He first tests that these properties have been set correctly by mocking out the object and overriding the configuration settings in the (dependency injection) container.

DZone.com: 2 years of Vim and PHP distilled


On DZone.com there's a new post from Giorgio Sironi with some of his tips for PHP developers that want to use VIM in their development - some handy tricks to help make you a more effective developer.



In the case of PHP development, you'll need to add some configuration and plugins to speed up your activities. Most of the responsibilities of an IDE - like testing and version control - are outsourced to the terminal while running Vim; however, there are some tweaks that make writing and editing code faster, along with aiding in discovery classes and methods in a PHP codebase.


He includes settings for your .vimrc to detect and load the right PHP functionality, using Command-T, functionality for autocompletion and the snipMate plugin for managing and using reusable code snippets.

Reddit.com: How and When do you use Bitwise?


In this new question to Reddit, there's a question about the usage of bitwise operators - when they might come in useful.



As I get deeper into PHP I notice some lower level functionality that looks like it could be interesting, maybe even useful. I'm trying (other than switching the hex value of a color) to figure out when Bitwise operators might come in handy. Any real world examples?


Responses to the post mention a few cases they'd be useful in - handling permissions, route matching and error reporting. You can find out more about bitwise operators in PHP the PHP manual.