2012: A Year in PHP
Another year has passed, and yet again we find ourselves reflecting on what has happened in the world of PHP over the past year. Let's take a moment to look back over our 2012 predictions and see how close we were!
In 2011 we said that major frameworks would start to converge on similar strategies for basic functionality. The PSR-0 standard defined a common autoloading strategy, and the release of Composer in March 2012 has really boosted the adoption of this standard across the most popular frameworks. The release of Symfony 2.1.0 in June brought in Composer as the dependency management solution of choice and the first stable release of Zend Framework 2.0 followed in September, also using Composer for autoloading and dependency management.
In March, the Drupal project announced that version 8 of their platform (currently due for release mid-2013) would be completely rebuilt on top of the Symfony components, an exciting development and certainly one which has started to bring the Symfony and Drupal communities together at conferences and other community events. It does appear to be the case that projects, even up to the framework level, are starting to move in the same direction, but the choice remains: Zend Framework 2 or Symfony 2? I think we can claim a point for this one!
Dependency Injection Containers
At the time we made this prediction, Symfony 2 was already in the wild and Zend Framework 2 was under heavy development with alpha versions available. We saw further releases of these two big hitters through 2012 and DIC (Dependency Injection Containers) have been a popular topic throughout the year at conferences. It's enabled practitioners to create testable, reusable code and has become a standard practice amongst practitioners of good PHP.
We said that caching would be a big topic of 2012 as large enterprises and other organisations start to leverage open source solutions for their high traffic web applications. Almost all projects that we have started in 2012 have had a varnish layer designed in from the start to achieve the high performance that our clients expect, and Edge Side Includes (ESI) has started to see more use in new applications - putting caching proxies, of which Varnish is one, at the core of the platform.
We'll claim a point for this one as we have seen caching being a really hot topic in 2012, and one which we expect to continue to see in 2013. Varnish has seen an increase in usage during 2012 of 39% (see http://trends.builtwith.com/Web%20Server/growth#!oneYear)
One of the most popular topics that has come up at conference talks in 2012 is Composer. We've mentioned it already in this write up, but if there was a top 10 for what has changed the face of PHP over the year, this would be #1. Not only has Composer been a conference talk topic in its own right across many events this year, it has also featured in talks about many other technologies. Support for Composer has become something that people working on open source PHP project libraries are proud to announce as a feature of their product - and quite rightly so! It has already become something that's almost expected for all PHP libraries - and pull requests on GitHub to add support for it across the board have become commonplace.
The old argument between PHP users and users of other languages has raged on. We are proud of PHP's roots in server-side templating, but the language has evolved into something completely different today. Because of this history, the PHP manual is focussed on the quick way of getting something done in PHP rather than what is necessarily the best practice, and 2012 saw the launch of a really great resource for developers: http://www.phptherightway.com/. It is a collection of recognised "best practices, options and good information" on using PHP and is a highly recommended read for all users of the language. The recent addition of comment voting on the PHP manual will hopefully promote good information over poor practice in the official manual over time, which will only benefit us all.
PHP5.4, PHP5.5, PHP5.2 and PHP5.3 (in that order...)
The 5.4 stable release of PHP came out in March, and since then it has seen 10 maintenance releases - bringing us to the latest stable release of 5.4.10 (at the time of writing).
Towards the end of 2012 we also saw the first alpha releases of PHP 5.5 - the next major release of the PHP 5 language. This will bring new features such as generators (simple iterators with the addition of the yield keyword in functions), the "finally" keyword (try, catch, finally), a new and redesigned password hashing API and various other improvements to the language core. It's worth mentioning that the current release is still alpha and new/deprecated features are still subject to change.
The w3techs usage statistics reports that PHP 5.2 is still the most popular deployment of PHP out there in the wild with 52.1% of all PHP deployments running on that version. The language hit end-of-life status back in 2010 and users of sites built on this old technology have been encouraged to upgrade to 5.3 as a matter of urgency.
PHP 5.3 is in second place with 42.9% of deployments. The PHP group announced that 5.3 would reach an end of life status in March 2013 - with these users being encouraged to upgrade to 5.4. It's important that existing users of 5.2 start to look at upgrading as the work required to jump two or even three major versions will quickly become problematic. A small minority of sites are still stuck on PHP 4 and PHP 5.1, but we won't talk about those...!
How did we code in PHP before the 5.3 release brought us closures? From being able to write PHP code directly into core functions like array_map() et al, to seeing frameworks like Silex gaining popularity, built on Symfony2 components and leveraging the coding style that having support for closures allow, this welcome language addition has made it easy for us to write better PHP.
For example how ugly would the code of the Pimple project be, but for the support of Closure within PHP?
Predictions For 2013
Now we come to the part where we try to predict what is going to happen in the land of PHP during 2013.
Framework Convergence ... Again
We predicted it last year and some massive steps were made towards achieving this goal. We think that 2013 will bring more efforts to be able to share modules between frameworks through the establishment of defined interfaces. These will be implemented by the framework core (a common approach to things like logging, authentication, etc). It only makes sense to build on what has already been achieved in 2012 with Composer and Packagist (the package repository that Composer uses).
Content as a Service
It's becoming more and more common for clients to ask us for a way of being able to create content and share it across many different sites and software platforms. Currently, the most popular CMS products force you to display the content you create through the templating system that is in-built to the platform you are using. We think that in 2013 we will start to see solutions for allowing a content repository to be able to push its content out to many different places - especially as more people consume data on a mobile platform.
Dependency Injection Containers Mark 2
With the previously-mentioned greater adoption of DIC within frameworks, more and more people have made use of DIC to resolve dependency management within their code. However this has lead to misuse by some and problems of an entirely different nature, especially within code libraries. As the wider community learns from these experiences good practices are formed. Dependency Injection needs to be considered when designing OO software rather than just ignored and left to the DIC.
BDD with PHPSpec and Behat
XUnit style testing frameworks seem to be losing favour within the community and the adoption of Spec frameworks and Behaviour Driven Development is set to increase in 2013. With the initial alpha release of PHPSpec 2 in October 2012 this alternative testing framework has given the PHP community a fresh perspective on testing and where it fits into the development process. This lean framework by design focuses on being a tool to help and support writing well structured OO code rather than provide mechanisms for validation. Used in conjunction with Behat, PHP now has the tools needed for full stack BDD. We predict a much greater adoption of these tools and BDD over 2013 and beyond.
Use and Misuse of Traits
Once PHP 5.3 reaches end of life status in March, framework and library developers will start to create releases with PHP 5.4 as a minimum dependency, allowing them to make use of traits. We anticipate that this will result in a great deal of code deletion from frameworks as multiple horizontal inheritance will allow a lot of boilerplate code from iterators (for example) to be removed and placed into traits.
This sounds like good news, and it is. However with great power comes great responsibility and this particular language feature is likely to be both used and abused! The community is always quick to learn from its mistakes however and we're sure that by this time next year traits will have had lots of good and some bad press.
PHP and You in 2013
What is on your horizon for the coming year? Is there anything we should have seen coming and didn't mention? Leave us a comment and let us know - and good luck with your PHP this year!