2011年7月29日星期五

Site News: Popular Posts for the Week of 07.29.2011

Popular posts from PHPDeveloper.org for the past week:

Maarten Balliauw's Blog: Windows Azure SDK for PHP 4 released


Maarten Balliauw has a new post announcing the release of the latest Windows SDK for Azure for PHP, version 4.



The Windows Azure SDK 4 contains some significant feature enhancements. For example, it now incorporates a PHP library for accessing Windows Azure storage, a logging component, a session sharing component and clients for both the Windows Azure and SQL Azure Management API's. On top of that, all of these API's are now also available from the command-line both under Windows and Linux. This means you can batch-script a complete datacenter setup including servers, storage, SQL Azure, firewalls, ... If that's not cool, move to the North Pole.


He includes a few things from the changelog including service management API support for SQL Azure, package scaffolders and various performance enhancements. You can find out more about the release and the latest on the project on the Microsoft Interoperability website.

2011年7月28日星期四

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

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

Symfony Blog: Symfony 2.0 (Release)


On the Symfony blog today the official announcement Symfony fans have been waiting for has been made - the first official version of Symfony 2.0 has been released.



After 12 preview releases, 5 beta versions, and 6 release candidates, I'm very proud to announce the immediate availability of Symfony 2.0, final version. Since the first preview release, published 18 months ago during the Symfony Live conference, the Symfony community has done an amazing work. The Symfony2 code quality would not have been the same without their outstanding work. Thank you!


Fabien takes a little time to thank the community that's backed the project and has contributed their own time and efforts to making it a success. He also talks about the code itself mentioning its emphasis on standards, its efforts to be as decoupled as possible and some of the innovations they've brought to the world of frameworks. You can grab this latest release here and can learn all about this new version through the Quick Start tutorial.

Devshed: Simple and Secure PHP Login Script


In this new tutorial on DevShed, they walk you through the creation of a secure login script that uses sha256 encryption, a captcha to prevent automated signups, XSS attack protection and several other features.



Recent advancements in PHP offer the developer a variety of tools to improve the security of login systems. [...] This programming tutorial will teach you how to create a simple, yet secure login script utilizing PHP using MySQL and bracing for XSS attack prevention.


Other features include no persistent logins, preventing direct file access, an idle timeout on the user session, protection against session fixation and anti-brute force measures. Full (procedural) code is provided as well as screenshots from phpMyAdmin showing the database table structure. You can grab the code for the project here.

Voices of the ElePHPant: Interview with Sean Coates


The Voices of the ElePHPant podcast has posted it's latest episode - an interview with Sean Coates (of Gimmie Bar).



Cal asks Sean his three questions about various projects and topics he's involved with:



  • Can you talk to us about what you see about the process of how PHP is developed and is this a positive or a negative?
  • Can you give us a quick synopsis of why Gimmie Bar moved from CouchDb to MongoDb and are you still confident that it was the right decision?
  • Can you talk a bit about your experience with Node.js?


You can listen to this episode either using the in-page player, by downloading the mp3

2011年7月27日星期三

Community News: Latest Releases from PHPClasses.org

Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHPDocumentor


Michelangelo van Dam has posted the latest in his "quality assurance in PHP projects" series today with a look at something that can make your life and documentation easier - PHPDocumentor.



Unfortunately I've come across too many lines of code that were just lines of code, no comments or annotations provided. So, in best cases I could guess the types and parameters, but in many it was too obfuscated. I already talked about usage of a code sniffer like PHP_CodeSniffer in my previous post where you can validate the usage of comments in the code. But forcing developers (using a pre-commit checker) into writing documentation with their code is not really a good thing.


He suggests using something like PHPDocumetor (there's other PHPDoc parsers including DocBlox and Doxygen out there) to automatically generate documentation for your code based on its comments, giving your developers easier web-based access to the contents. He includes some sample docblocks for a class/method and gives an example command line call to build docs based on a project. A screencast and screenshot of the generated site shows the results of the run.

Zoomzum Blog: 10 Powerful PHP Regular Expression For Developers


On the Zoomzum blog there's a new post with ten regular expressions PHP developers can use to accomplish some common tasks (like email validation and date formatting checks).



Regular expression for the PHP developers, on of the most popular tool for validating data is the regular expression. In this list we provides some validation - string match, password match validation, email address validation, date format and many more which helps developer to make their application more fast and easy to execute. [...] Have you note that, regular expressions are more slower than the basic string function, its takes a short time to execute than any others.

Included in their list are things like:



  • Password Match Validation
  • Validate URL
  • Validate URL using Preg_match
  • UK Postcode Validation
  • SSN,ISBN and Zipcode Validation


A few of these could be done with either one or two string calls or some of the filtering functions that are included in PHP.

2011年7月26日星期二

Community News: Latest PECL Releases for 07.26.2011

Latest PECL Releases:

Johannes Schluter's Blog: Improvements for PHP application portability in PHP.next


In a new post today Johannes Schluter talks about the upcoming version of PHP and three of the things it features: no more short tags, no more magic quotes and the dropping of the enable-zend-multibyte compile option.



I was writing about PHP.next before, many things improved there meanwhile. Most notably we have a committed version number: The next PHP release will be called PHP 5.4. The topic I want to talk about today is "Improved application portability" which covers multiple small changes which aim at making it simpler for developers to write applications working on any PHP setup.


The first two will be immediately familiar to any PHP developer, but the third might be a little more elusive. This option was used to compile in multi-byte encodings to use for data in an application. Unfortunately a good implementation (that didn't use mbstring) couldn't be found, so they're removing the feature.

Liip Blog: PHPDoc Compilers and the @inheritdoc


On the Liip blog there's a new post that compares some of the popular PHPDocumentor-formatted comments parsers. They're looking specifically at the support for interfaces, not just the usual classes and methods.



The interfaces define the standard and are extensively documented. The implementation was built by copying the interfaces and implementing the methods. Now we have the documentation comments duplicated, which is a pain to maintain if we clarify or change anything in the interfaces documentation. [...] In PHP, there is a couple of doc compilers. While they basically all follow the same syntax as Java uses, none of them gets everything right unfortunately.


The four covered are PhpDoctor, DocBlox, PHPDoc and Doxygen. They look at things like namespace support, the inheritance information they generate and if it correctly uses the "@inheritDoc" tagging functionality.

2011年7月25日星期一

Community News: Latest PEAR Releases for 07.25.2011

Latest PEAR Releases:

Christian Weiske's Blog: Installing PHP extensions for phpfarm


Christian Weiske has a new post to his blog today on how to get PHP extensions installed for phpfarm, the tool that lets you switch between multiple PHP versions on the same machine.



When using several PHP installations with phpfarm, installing PHP extensions is not always easy - mostly because Pyrus is very strict about package files - and many of the packages in PECL unfortunately have invalid non-validating package.xmls.


The installation follows most of the normal process with one exception - you use the phpfarm phpize and point the configure to use the phpfarm ini configuration file then enable it as usual.

Symfony Blog: Symfony2: The Roadmap to Final


On the Symfony blog Fabien Potencier has posted about the roadmap to a final release for the Symfony2 version of the popular framework including some of the things that will and will not change after the release.



We are now ready to release Symfony 2.0 final. As we have made some significant changes in the last couple of weeks, we are publishing another release candidate (RC5) today and we will wait for a week before releasing Symfony 2.0 final on Thursday 28th.


The upgrade to Symfony2 is just a few commands away and there's a large list of components that are set and will not be changed moving forward including the DependencyInjection, Finder, Locale, Routing and Validator.



Symfony 2.1 will be the first release with all the components with a public stable API. And for components that already have a public API in 2.0, 2.1 will be the occasion to add even more classes and methods to it.

2011年7月22日星期五

Site News: Popular Posts for the Week of 07.22.2011

Popular posts from PHPDeveloper.org for the past week:

Philip Olson's Blog: One way PHP may capitalize on its popularity


Philip Olson has a (tongue-in-cheek) post to his blog today about how PHP can make the most of its popularity financially.



Today Rasmus mentioned that he received a $500 offer for the php.net domain name. Discussion ensued, which ultimately led to the indisputable belief that php.net is worth over 10 million US dollars. Therefore, let's think about this further...


He compares the worth of several popular languages (with a "reliable source") and does some math where PHP.net account holders would profit from the popularity over other languages. On a bit more serious note, though, he points out a few ways that you can contribute or get involved in the PHP project on several fronts:


Sameer Borate's Blog: Read the version of a PDF in PHP


Sameer Borate has a quick post to his blog today with some code that lets you read the version of a PDF document programmatically without a dependency on a PDF extension or library being installed.



The following [example] is a very short code to read the version number of a PDF document using PHP. I needed this recently during a PDF processing app developed in PHP. As Adobe uses different compression methods in various versions, it becomes necessary to be able to identify the version of the PDF under work.


The code opens the file with a fopen and parses a certain line for the major and minor version. The PDF extension for PHP can do something similar with the pdf_get_value function passing in either "major" or "minor" as the second parameter.

2011年7月21日星期四

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

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

Voices of the ElePHPant: Interview with Rafael Dohms


On the Voices of the ElePHPant podcast has posted their latest interview with a member of the PHP community. This time it's Rafael Dohms, a member of the Brazilian PHP community.



Cal's questions for Rafael are related to


  • The Brazilian PHP community has an umbrella organization that supports the local communities - can you describe how this works?
  • Can you explain the differences in the communities between the two countries [USA and Brazil]?
  • What one thing from the Brazilian PHP community would you like to see other communities use?



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

Bradley Holt's Blog: Exploring RabbitMQ and PHP


In a new post Bradley Holt looks at some of his exploration into the combination of RabbitMQ and PHP as a possible platform for messaging between process (or applications).



I'm exploring the possibility of using RabbitMQ for an upcoming project. RabbitMQ is a free/open source message broker platform. It uses the open Advanced Message Queuing Protocol (AMQP) standard and is written in Erlang using the Open Telecom Platform (OTP). It promises a high level of availability, throughput, scalability, and portability. Since it is built using open standards, it is interoperable with other messaging systems and can be accessed from any platform.


He goes through the full process - installing RabbitMQ via MacPorts, grabbing the latest copy of the librabbitmq library and installing it and finally installing the AMQP extension for PHP so they can communicate. He includes some simple code that connects to the queue and sends a "hello world" message out to the connection bound to "routeA".

Anthony Ferrara's Blog: Random Number Generation In PHP


Anthony Ferrara has a new post to his blog today looking at true random number generation as it relates to predictability and bias. He also talks about a method/tool you can use (based on RFC 4086) to generate truly random numbers - PHP-CryptLib.



When we talk about "random" numbers, we generally talk about two fundamental properties: Predictability and Bias. Both are closely related, but are subtly different. Predictability in reference to random numbers is the statistical problem of predicting the next value when knowing any number of previous values. Bias on the other hand is the statistical problem of predicting the next value when knowing the distribution of previous values.


He looks at how predictability can effect true random number generation and a common mistake in generation related to bias in the calculation method. He talks about some of the functions PHP includes to work with randomness, but notes that they all have their flaws. He points to the PHP-CryptLib package as a solution (adhering to the guidelines in RFC 4086 for randomness). He includes some sample code of how to use it to generate random numbers, tokens and sets of bytes. You can find the full source over on github.

2011年7月20日星期三

Community News: Latest Releases from PHPClasses.org

Tom Jowitt's Blog: Streamlined PHP Development - Part II


Tom Jowitt has posted the second part of his series looking at setting up a streamlined PHP development environment in part two covering some of the basics of the build.



In the first part of this series we looked at setting up our Apache installation to make life easier. Now that the basics are sorted we can start looking at how to structure our development environment and run some basic build tasks using Phing.


He shows how to use the PEAR installer to get Phing installed (including all of its dependencies) and creating the base directory for it to use in your build. He includes the contents of some of the configuration files (available on github) to set up some properties and the steps to the build process in the build.xml. He explains each part of the build process and includes some screenshots of the end result.

Matthew Weier O'Phinney's Blog: Converting DocBook4 to DocBook5


In this new post to his blog Matthew Weier O'Phinney looks at the steps he took to convert over the documentation for the Zend Framework 2 from the DocBook 4 formatting over to DocBook 5. Included in the post is some of the (PHP and bash) code he used to make the switch.



Within the Zend Framework 2 repository, I recently performed a conversion from DocBook 4 to 5. [...] Interestingly, for DocBook5 being available in beta since 2005 and an official standard since 2009, there is very little material on migrating from DocBook 4 to 5.


Right from the start he came across a few problems with the included conversion process that're a part of the "db4-update.xsl" definitions.
He has a list of eight steps he had to perform on the current DocBook 4 formatted documentation to make the conversion work smoothly including:



  • Identify files containing entity declarations, and skip them.
  • Run the XML file through the db4-upgrade.xsl stylesheet and restore XML entities from the previously placed markers
  • Fix programlisting elements (replaces entities with original text and wraps in CDATA).


He details these steps in a few different sections talking about handling the entities, creating some helper scripts and how to put the two code parts together in a single bash script that can be run on the entire documentation set. If you're just looking for the code, you can find it on his github account.

DZone.com: What new feature in PHP 5.4 is the most important to you?


In a new post to DZone.com today Giorgio Sironi asks developers what new feature of PHP 5.4 is the most important to you and your application development?



Recently, the voting process for PHP 5.4 open to committers and users have been closed. We now have a clear picture of what will make the release and what will be left out. Some of these features (traits, web server) were already in, while other have been just voted and will be completed before the general availability of the release.


He lists out some of the major changes that'll be coming in the 5.4 release including traits, dereferencing, the built-in HTTP server, closure type hinting and the upload progress feature previously only in an extension. The end of the post includes a poll for you to give your feedback on what you think is the most important. As of the time of this post, the array dereferencing has pulled into the lead with traits coming in second.

2011年7月19日星期二

Community News: FrOSCon 2011 Schedule Released


The FrOSCon event is a yearly conference held at the University of Applied Sciences Bonn-Rhein-Sieg in Germany. This year's event is being held August 20th and 21st and they've just released the schedule for this year's event.


Included in the list of sessions are topics like:



  • Mailing list project management
  • Openstack deployment
  • Behavior-driven development
  • Using git for version control
  • MySQL performance tuning
  • Using Ant for application build and deployment
  • Best practices for creating high load websites
  • Test=driven development


You can see the complete list of the topics and speakers here as well as information on other events, iCalendar links for reminders and an XML of the sessions.

Gonzalo Ayuso's Blog: Populating datagrid techniques with PHP


In a new post to his blog Gonzalo Ayuso looks at the code required to populate a jQuery data grid with the records as pulled from a (MySQL) database.



Today I want to speak about populating datagrid techniques with PHP. At least in my daily work datagrids and tabular data are very common, because of that I want to show two different techniques when populating datagrids with data from our database. Maybe it's obvious, but I want to show the differences.


He uses "old school spaghetti code" rather than a framework to keep things simple and pulls the data from the database with a PDO connection. This information is then manually pushed into an HTML table and the data grid functionality is applied to it. The other method involves a little bit of JSON magic that the data grid library pulls in and populates for you, still appending rows to a table.



He notes that the second method seems faster to the user since the page and table are rendered first, but it also comes at the cost of more than one HTTP request.

Sameer Borate's Blog: Tail functionality in PHP


Sameer Borate has posted an alternative to "tail" that you can use to find the last X number of lines in a log file you'd like to follow without having the overhead of parsing the entire file.



Frequently one needs to get the last few lines of some log files, whether php error logs or Apache logs. Most of these file sizes run into megabytes, which makes it difficult and time consuming to remotely open them using ftp. [...] The [example] is a simple but useful 'tail' implementation in PHP. I've encapsulated the tail function in a 'LogRead' class, which can be further enlarged by adding other useful log functions.


His code opens a file pointer to the requested log, grabs the file size and uses the fseek function to move the pointer to the line/location you've requested. Obviously, if the requested lines of data is large, it will still have some overhead, but this is a much better way for keeping track of the latest additions to a log. You can then use the "tail" method on the "LogRead" class to grab just the lines you want.

2011年7月18日星期一

Community News: Latest PEAR Releases for 07.18.2011

Latest PEAR Releases:

TutsWall.com: CodeIgniter from scratch - Introduction & Installation


From TutsWall.com there's a recent tutorial (pretty brief) about getting started with CodeIgniter.



Developing web application from scratch is always a painful task. This where frameworks comes to help us, but learning frameworks will at-least take some decent learning curve. But there are some frameworks that is very easy and fun to learn and develop applications and CodeIgniter is of of them.


They cover the download of the framework, ensuring it's working by hitting the main page and creating a simple controller and view to show you where some of the pieces go.

Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHP_CodeSniffer


Michelangelo van Dam has posted the next part in his "QA in PHP development" series to his blog, a look at PHP_CodeSniffer, a tool that can be used to keep the coding standards of your application in line.



PHP_CodeSniffer is probably the most convenient tool out there to analyze your source code and to verify it complies to company policies. Although it's debatable why source code should follow strict guidelines, it's only a matter of time before you discover yourself that it pays off to have a code base that appears to be written by one developer.


He talks about how it works to keep every brace in the right place and format the same through out all of your files. He also mentions that its standards are flexible and can be modified as you might see fit. He looks at the installation process (both manual and through the PEAR installer) and how to use it to analyze your codebase. He's even included a short screencast in the post so you can see the results first-hand.

2011年7月15日星期五

Site News: Popular Posts for the Week of 07.15.2011

Popular posts from PHPDeveloper.org for the past week:

Michelangelo van Dam's Blog: Quality Assurance on PHP projects (and PHPLint)


Michelangelo van Dam has started a new series of posts on his blog about quality assurance in PHP projects with this introduction and a look at the first tool on his list PHPLint.



Quality Assurance has become an increasing important part of web application development, especially with PHP applications. [...] Luckily there are a lot of tools available that allows you to increase quality of these web applications, and the best part is they are all based on PHP! Let's have a quick look at what tools are interesting to start improving quality assurance on your PHP projects.


The first tool, PHPLint, helps you validate code against syntax errors and is built into the command-line PHP you already have. He describes its use, both on the command-line and in a pre-commit hook on his git repository



For more PHP QA-related information, he also points out the book from Sebastian Bergmann and Stefan Priebsch as a good reference too.

Community News: An Effort to Deprecate the MySQL Extension


According to this new post to the PHPClasses.org blog today, the core PHP development team has put plans in motion to try to remove the original MySQL extension from the default PHP installation.



PHP core developers are planning to kill the PHP original MySQL extension. If you are using MySQL in your PHP applications for a long time, this may seriously affect you.


Right now it's just in the proposal states (as suggested by Philip Olson) but, if fully acted upon, could have large implications on a number of PHP applications currently using MySQL. For now, though, Philip is only suggesting an education of the PHP user base that they should migrate to either pdo_mysql or mysqli for the future of their apps. Most of the comments following in the mailing list thread are supportive of the effort. They note that it won't be an easy task and, in the end, will still be a "bitter pill" for developers to swallow when the switch is finally thrown.



For the full thread of this discussion, see here and keep clicking through on the "next in thread" link.

Brian Swan's Blog: PHP Driver for SQL Server - Request for Feature Feedback


Brian Swan is asking for user feedback about the future of the Microsoft's SQL Server driver for PHP based on a post in the team's blog.



I want to make sure that his request gets in front of lots of eyes, so I'm re-posting his request here (below). Jonathan included some links in his post so you can learn more about what the team is considering for the next release of the driver, but he didn't elaborate on "Buffered Queries".


They suggest a few features and ask for choices on which would be the most important to you as a developer - Always On support, SQL Server Serverless Express support, Buffered queries and LOB streaming support in PDO_SQLSRV. To give feedback, send an email to the address mentioned in the post or on twitter/their forums.

2011年7月14日星期四

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

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

DevShed: PHP Object Oriented Programming using LSP


In another part of their series looking at the SOLID principles of software development, DevShed focuses again on using LSP (the Liskov Substitution Principle) to help you organize your application (part one is here).



Even though its formal definition is somewhat hard to grasp, in practical terms it states that methods defined in a base class (or interface) and their derivatives must have the same signature, preconditions should be weakened in the formers, and post-conditions should be strengthened. In addition, if methods in subtypes throw exceptions, they should be of the same type as the ones thrown by the parent abstraction.


You'll need to read the previous tutorial for things to make sense here. They take off running from there, though and get straight into refactoring the previous example to correct a violation of LSP. In the end you'll have a layout/view system that correctly follows the principles and is pretty simple to use too.

Voices of the ElePHPant: Interview with Bill Karwin


The Voices of the ElePHPant podcast has release their latest episode - a new interview with Bill Karwin.



Cal's "three questions" for Bill talk about both general development and SQL topics:


  • Can you describe for us what second system syndrome is and why you think Zend Framework 2 falls into it?
  • What's the biggest mistake you see project developers making when it comes to SQL?
  • Can you briefly explain what is a SQL anti-pattern and give a few examples?



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

2011年7月13日星期三

Community News: Latest Releases from PHPClasses.org

PHPClasses.org: Book Review - PHP 5 CMS Framework Development - 2nd edition (Packt)


On PHPClasses.org there's a new post reviewing a book from Packt Publishing, "PHP 5 CMS Framework Development" (a second edition) by Martin Brampton.



In this review I focus on the changes between the editions of the book, which are brief and objective, since the core of the work remains the same and with the same quality. [...] In sum, I recommend reading this book to those looking forward to improve their skills in PHP, or intend to create new frameworks. To put it simply, a good book to read, and with new tricks to learn.


He (the reviewer, Alexandre Altair de Melo) briefly looks at these differences between the versions, with the largest being in Chapter 15 - the building of a sample application to apply all of the theory learned in the rest of the book. You can find more information about the book on Packt's website here.

PHPBuilder.com: 6 PHP Performance Tips for Producing Highly Optimized Code


On PHPBuilder.com today Jason Gilmore offers some performance tips to make highly optimized code without having to use something like HipHop to get closer to the speeds you might need.



While HipHop may seem a rather esoteric solution to the performance problem, a method lies within the perceived madness; maintaining the website logic using PHP code allows Facebook to maintain a code base which remains accessible to a larger number of developers, with the added bonus of being able to deploy blazing fast C++ code. Of course, incorporating HipHop into your infrastructure might not be ideal, but that shouldn't stop you from striving to produce highly optimized PHP code. Read on to learn more about several straightforward steps you can take to boost PHP performance.


Some of the tips included in his list are obvious but could easily be overlooked like:



  • Upgrade your PHP distribution
  • Tone down error reporting
  • Use PHP's native extensions whenever possible
  • Use a PHP accelerator


Take a look at the full post for other suggestions and descriptions of each.

CodeForest.net: Android JSON-RPC client and PHP Zend Framework server


In a recent post to CodeForest Luka Peharda shows you how to create a JSON-RPC frontend for your application based on the Zend Framework.



XML-RPC rules, but the amount of data it generates is its big disadvantage. This is where JSON-RPC steps in. Data it generates is significally smaller, but this isn't suprising as JSON is known as fat free XML.This articles is based on my earlier Android XML-RPC article. Its PHP code and Zend Framework setup will be used so you should go through it if you haven't earlier (at least as far as XMLRPC Android client chapter).


You need to have some of the base code from the previous article in place to follow along, but if you're experienced with Zend Framework, keeping up won't be a problem. He uses this JSON-RPC client that was made for use with a ZF application and creates a basic jsonAction to handle the request. He then uses this Android JSON-RPC library to connect from the Android application and fetch some basic data.

2011年7月12日星期二

Community News: Latest PECL Releases for 07.12.2011

Latest PECL Releases:

Lorna Mitchell's Blog: PHP Returning Numeric Values in JSON


Lorna Mitchell has a quick reminder about an issue in the new joind.in API version - everything was being returned as strings, even integers.



A few weeks later (my inbox is a black hole and it takes a while to process these things) I fell over a throwaway comment to an undocumented constant JSON_NUMERIC_CHECK, and I added the constant name to my todo list. In the time it took for me to actually get around to googling for this, some wonderful person updated the PHP manual page (this is why I love PHP) to include it as a documented option, and someone else had added a user contributed note about using it.


This option, JSON_NUMERIC_CHECK, tells the json_encode function to property consider numbers in its encoding process. It applies globally, so if there's an instance where you don't want something assigned as a number, you might need to go with another, more flexible JSON encoding option. You can find information about this and other possible options json_encode can take on its manual page.

Voices of the ElePHPant: Interview with Chris Spruck


The Voices of the ElePHPant podcast has posted its latest episode, an interview with Chris Spruck, the head of the Atlanta PHP User Group.



Cal asks Chris three questions about user groups and their dynamics.


  • What's been your biggest success in the Atlanta PHP User Group?
  • How do you keep your members interested in the group and its topics?
  • What has been the best part about being a part of a user group for you?



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

Gonzalo Ayuso's Blog: Database Abstraction Layers in PHP. PDO versus DBAL


In this new post to his blog, Gonzalo Ayuso compares two technologies that can make working with databases in your applications simpler - PDO and the Doctrine2 DBAL layer.



In fact DBAL isn't a pure database abstraction layer. It's built over PDO. It's a set of PHP classes we can use that gives us features not available with 'pure' PDO. If we use Doctrine2 we're using DBAL behind the scene, but we don't need to use Doctrine2 to use DBAL. We can use DBAL as a database abstraction layer without any ORM. Obiously this extra PHP layer over our PDO extension needs to pay a fee. I will have a look to this fee in this post.


He includes a few simple benchmarking scripts that compare similar operations done by either, including memory usage and execution time. PDO comes out on top, obviously, because it's an extension versus a set of PHP libraries that need to be included in the application. He does include examples of a few things he likes that DBAL does that PDO doesn't by default - a transactional mode, type conversion, a simpler binding interface and the ability to nest transactions.

2011年7月11日星期一

Community News: Latest PEAR Releases for 07.11.2011

Latest PEAR Releases:

PEAR Blog: PEAR in July 2011


On the PEAR blog there's a new post talking about some of the things coming up in July that you might want to take note of.



There's nothing quite like having your blogging system go MIA for a while to give your community an overwhelming impression that no one is home. Thankfully; despite the radio silence between updates there's quite a lot to talk about!


The updates include mentions of several new PEPr proposals for packages related to Mercurial support, Twitter and holiday date validation. There's also a mention of the large amount of PEAR channels that are popping up and the future of PEAR in PHP 5.3+ with Pyrus.

Artur Ejsmont's Blog: How to structure a Zend Framework application and it's dependencies


Artur Ejsmont has a recent post to his blog with some recommendations on how to structure a Zend Framework application and its dependencies to make it both easy to maintain and extend in the future.



I don't mean to be negative but I am not too happy about the web application structure that most articles and books present. In Zend Framework world controller seems to be the place when things get done. Controller is the workhorse and this is where all the logic seems to be buried.


He talks about the non-reusability of controllers outside of a web-based environment and the bad habits that can come from depending on variables of that environment. He's come up with a diagram of how he thinks a good, modular Zend Framework application should be structured where the emphasis is on Services, not web requests. He looks at database aware/agnostic services, working with models, third-party code and working with external systems. He also touches on the "V" and "C" in MVC, noting how the views and controllers still fit into the mix.

Brian Swan's Blog: Performance Tuning PHP Apps on Windows with Wincache


Brian Swan has a new post to his blog sharing some tips you can use to get the best performance out of your Windows applications by tuning Wincache.



A few weeks ago I wrote a post that showed how to improve the performance of PHP applications on Windows by using the IIS output caching module. Using the output caching module can have significant positive impact on application performance since pages are served from cache without executing any PHP code. However, this very strength can also be a drawback depending on how your application is built. Because entire pages are cached, using output caching may not be ideal for pages that have multiple data sources.


He points to the Wincache extension as an alternative to the full-page caching with it's built-in opcode caching (you get for "free" just by installing). He mentions this and a few other features that come with it like the ability to cache to a file and to normalize file paths for more efficient seeking of files. He also focuses on partial caching with a specific example of caching user data for use through out the application. A bit of code and some screenshots are included to show the performance boost this can give.

2011年7月8日星期五

Site News: Popular Posts for the Week of 07.08.2011

Popular posts from PHPDeveloper.org for the past week:

SWAT Blog: Python VS PHP


On the SWAT blog there's a recent post comparing Python and PHP and some of the reasons the author prefers the former over the latter.



Even after just one week using Python, I remember why I'll always prefer it - it empowers me as a programmer. In the Python community, they refer to it as the "batteries included" philosophy - with the mere inclusion of a library, anything becomes possible. Combine that with clean and readable syntax, fluent interfaces, powerful list comprehensions, list slicing, an interactive console, and too many other features to mention, it's clear to see why.


He illustrates one of the differences between the two languages in the handling of things as objects versus strings. He recommends developers at least take a look at Python as an alternative to some of the usual PHP you might be used to.

Martin Sikora's Blog: Google Chrome Extension: PHP Ninja Manual


In a new post today Martin Sikora has points out a Google Chrome extension he's created that lets you view some of the basics of the PHP manual without leaving the browser.



Finally, I released my extension for Google Chrome called PHP Ninja Manual (Ninja - because I like Avinash Kaushik'sblog and he always call people who are very skilled in something as "Ninjas"). I was always lazy to open PHP documentation every time I had to look at some method definition and its parameters so I made this extension which is actually preparsed official PHP manual available instantly in a popup window.


You can see a screenshot of it in action here including the auto-complete searching and the example of the function's summary details. If you try it out and have feedback, go over to the forum for it and leave your comments.

Community News: Launch of CSI:PHP


Jeremy Kendall has started up a new blog that's a sort of "WTF in PHP" listing of some of the random (and bad) code that he comes across daily - CSI:PHP.



It all began with a new gig and an amazingly horrific codebase. I began tweeting the most unbelievable, most frustrating snippets I could find. After quite a few of those tweets, Chris Hartjes replied with, "Looking at your tweets I cannot even fathom what your job is. CSI:PHP ?" A concept was born.


Some of the posts so far include eval() hell, a bad use of preg_replace and a bad method for calling mail(). Currently there's not a way for others to contribute their own code WTFs, but from what I hear it's possible for the future.

2011年7月7日星期四

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

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

Voices of the ElePHPant: Interview with Michael Maclean


The Voices of the ElePHPant podcast has release their latest episode today - an interview with Michael Maclean, a developer on the Cairo PHP project.



Cal asks Michael his "three questions" about his



  • Explain to us what Cairo PHP is and why PHP developers should be interested in it.
  • What is your role in the project and how did you get involved in such a unique project?
  • Give us some examples of some real-world projects that use Cairo PHP.


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

Kevin Schroeder's Blog: Authentication Using Zend_Amf


Kevin Schroeder has a new post to his blog today showing how you can use the Zend_Amf component in your Flex+PHP application to authenticate users with the same authentication structure the rest of the application uses.



I forget why, but a few days ago I started doing some digging around with authentication in Zend_Amf_Server. I had figured that I would add an adapter to the Zend_Amf_Server::setAuth() method and that would be it. But I was wrong.


Zend_Auth is used to validate the login information that's passed along and the Zend_Acl checks to see if they have access. To make this work for a connection from Flex, you need to make an authentication adapter and add it (as well as a basic ACL) into your Zend_Amf_Server call.

2011年7月6日星期三

Community News: Latest Releases from PHPClasses.org

Matthew Weier O'Phinney's Blog: Proxies in PHP


In a new blog post Matthew Weier O'Phinney has taken a look at proxy objects (the Proxy design pattern) and how it differs from some of the other popular patterns.



Of the other patterns mentioned, the one closest to the Proxy is the Decorator. In the case of a Decorator, the focus is on adding functionality to an existing object -- for instance, adding methods, processing input before delegating to the target object, or filtering the return of a method from a target object.


Proxies stand in for objects and have several benefits for your application that may or may not need all of the overhead a full object could cause. Matthew focuses on one benefit in particular - consuming and controlling access to another object. He sets up a problem of wanting to use properties/methods on objects that aren't exposed directly (like a protected method). His solution is a proxy layer class on top of the original object. He includes a few "gotchas" to look out for when using this technique including overwriting all necessary methods and copying over all of the needed properties.

Freek Lijten's Blog: Git commit hooks using PHP


In this new post from Freek Lijten he looks at a set of git commit hooks written in PHP for making things happen before, during and post commit.



Git hooks are usually found inside the .git/hooks folder of your git repository. Git tends to provide sample hook files there which are postfixed with a .sample extension. These examples are written as shell scripts. Take a look at them if you want, but today we're talking PHP!


He briefly touches on the types of hooks you can set up and includes two example scripts showing a pre-commit lint test for the changed files and a check during the commit on the message given for a certain standard (in their case, it must start with a three letter code).

2011年7月5日星期二

Community News: Latest PECL Releases for 07.05.2011

Latest PECL Releases:

Voices of the ElePHPant: Interview with Nicholas Zographos


On the Voices of the ElePHPant podcast there's a new episode interviewing Nicholas Zographos, the head of the Pittsburgh PHP User Group.



Cal's three questions revolve around Nicholas' work with the group:


  • How many members do you have at a meeting, on your mailing list and what do you do to bring those members closer together.
  • What is your meeting structure?
  • How do you handle the variety of skill levels in the group?



You can listen the usual three ways - either through the in-page player, by downloading the mp3

Ibuildings techPortal: DPC11: Day 2


The Ibuildings techPortal has posted the summary of Day 2 of the Dutch PHP Conference from Marco De Bortoli with some of his experiences from this year's event.



This year as part of the Ibuildings team I attended the Dutch PHP Conference for the first time. What can I say? Well, it was an unbelievable experience; I enjoyed every moment spent there. [...] There was also the high quality of the presented talks, but also for the great opportunity to spend good time with my colleagues at Ibuildings and people from other companies all around the world.


He mentions some talks specifically like Helgi's "First Class APIs", "Managing MySQL" by Thijs Feryn, a look at Modular Architecture from Kore Nordmann and Tobias Schlitt as well as David Zülke's map reduce session.



One thing I really appreciated about DPC was the Open Source and Open Knowledge spirit found there. Speakers were not there just only to talk and present something, they were there more to share their own knowledge and to share ideas and maybe a new solution to their problems. This, in my opinion, is one of the best things I took with me from DPC.

Nils Luxton's Blog: Installing PHP 5.4.0alpha1 into Wampserver


Nils Luxton has written up a guide you can follow to get the latest (non-production) release of PHP - v5.4.0alpha1 - up and running on your machine in your WampServer instance.



I wanted to do exactly that, and at work we use WampServer so we can easily switch between PHP versions (and it also makes enabling/disabling extensions and options very easy - if you develop on Windows, check it out). Assuming you have WampServer installed, it is fairly trivial to manually install new versions of the AMP trifecta.


There's a few things you'll need to download to get things up and running (besides the new PHP version) but the rest of the guide is simple configuration and startup. If all goes well, you should be running the alpha in less than ten minutes.

2011年7月1日星期五

Site News: Popular Posts for the Week of 07.01.2011

Popular posts from PHPDeveloper.org for the past week:

Elated.com: Object-Oriented PHP: Autoloading, Serializing, and Querying Objects


On Elated.com today there's the fourth part of their series looking at object oriented programming in PHP. This time the focus is specifically on autoloading classes, making objects into strings (serialized) and introspection.



If you've read all the articles up to this point then you're already familiar with the most important concepts of object-oriented programming in PHP: classes, objects, properties, methods, and inheritance. In this final (for now, at least!) tutorial in the series, I'm going to tie up some loose ends and look at some other useful OOP-related features of PHP.


He looks at each of the three topics above and includes code for things like a simple autoloader, object serialization, using sleep/wakeup and an example of using functions like get_class, get_class_methods and get_object_vars to do introspection on your classes and objects.

Chris Shiflett's Blog: Sorting Multi-Dimensional Arrays in PHP


In a sort of "remind himself later" kind of post, Chris Shiflett has shared a quick example of a common task PHP developers face sorting a multi-dimensional array.



Every time I need to sort a multi-dimensional array in PHP, I have to remind myself how to do it. It's not quite as quick and easy to look up as most things, so I'm going to blog a quick example. I've always felt like there must be a better way to do this, so please let me know if there is, and I'll update this post accordingly.


His method sorts a multi-dimensional array of user data using the array_multisort function together with a list of the usernames in each record. In the comments, people recommend using usort instead with a callback+closure combo that keeps things nice and clean.