Yesterday, the PHP community proudly announced that they have released
PHP 5.3. While only the minor version number went up, this is still a significant release containing many new features. Maybe even more important than these new features are several features that have been deprecated. These are features that have been in PHP for legacy reasons, but best practices generally already advised against using them, and now the features are formally deprecated. In a future PHP version they will disappear entirely.
At our
Techportal Cal Evans gave
an overview of the important changes, to make migration easier for developers. In this post,I'm going to look at the migration from a less technical angle, and explain when migration to PHP 5.3 is a good idea and when not.
What makes PHP 5.3 worth your attention?
First of all, PHP 5.3 is the most significant release of PHP since PHP 5 itself was released. If it had not been for the fact that full UTF-8 support is not yet ready, this release would have been called PHP 6. Where most new releases of PHP contain subtle changes and new functions, a significant release such as PHP 5.3 introduces changes to the language itself.
I won't dive into details on each of these new features, there's an overview available on
PHP's official website. What these features have in common, is that they improve the maturity of PHP as a dynamic language. Features such as closures and late static binding make the development of complex applications easier, and changes to the exception handling mechanism and the introduction of a garbage collector make PHP applications more robust.
A second reason is that as time goes on, many of the open source projects that are built using PHP, will move to PHP 5.3. While they have an interest in remaining compatible with PHP 5.2, over time a good amount of them will migrate. To continue to benefit from these projects and to make sure that the projects you use are still supported, it is a good idea to migrate to PHP 5.3.
How should you handle a migration project?
Migration projects can be cumbersome and time consuming. I always recommend a 2-step approach:
- A compatibility migration; in other words, changing your application as little as possible, just makeing sure it runs on the new version. This means looking at the migration guide and analysing your application to see what things you may need to change.
- A feature migration; this means taking advantages of the new features that PHP 5.3 offers. This (optional) step means analysing the application and its architecture and identifying where the benefit of the new features outweighs the cost of changing them.
About 2 years ago, I did a webinar on PHP 4 to PHP 5 migration, and the part of that webinar that discussed the migration process, is still relevant. The slides for this webinar are
available here and the relevant parts are slide 14 to 17.
Frameworks, libraries and tools
If you have developed your own set of libraries and tools, or even a framework, the migration is something to carefully consider. If you use these tools in applications that need to run on non-5.3 environments, you may have to wait before you can migrate them to 5.3. Especially if your tools or libraries are used by third parties, you may have to support older versions. If this is the case, it's useful to draft a company guideline so that the entire development team is aware of where it's acceptable to use PHP 5.3 code, and where not.
Need help?
We have been looking at PHP 5.3 for quite a while before it was released, so if your developers are occupied and you could use some help with migrating to PHP 5.3, or if you would like a training course on the new features, just contact us (
UK or Internationally,
Netherlands or Belgium), and we'll help you out.
A word of gratitude
Although there are several companies that support the development of PHP, PHP 5.3 most of all is the result of the hard work of the core PHP development team. It is their dedication and support that allows all of us in the PHP world to do the things we do, and we owe them a big thank you, so thanks, and may we see many more PHP releases in the future!