The enormous strides that WordPress has taken as a platform in the past 12 years have been mirrored by developments around the language it’s written in: PHP.
It’s a language that has attracted more than its fair share of criticism, but there have been significant improvements in the language and the wider ecosystem in recent years.
In this article, we’ll cover what you need to know as a developer to keep your PHP skills up to par for WordPress and the wider web beyond.
Let’s start with a quick review of the language itself and then run through the best resources for keeping your skills sharp and up-to-date.
How PHP Conquered The World
PHP has been on the scene now for 20 years and dominates the web development landscape. It’s used by over 80% of websites and was installed on over a quarter of a billion websites as recently as 2013.
It also remains extremely popular in the wider development world, placing fifth in the list of most-used programming languages in Stack Overflow’s 2015 developer survey.
PHP’s relatively easy learning curve and widespread availability have long made it an early favourite of newbie programmers – and its adoption by successive waves of CMS systems such as Drupal, WordPress, and Joomla! have contributed substantially to its overall ubiquity.
The Promise of PHP7
Sitepoint has a useful overview of resources for PHP developers to consult to get up to speed on changes coming down the pipeline, and sites such as Engine Yard are also running an introductory series to the new version.
What the next generation of PHP will mean for WordPress has been a hot topic recently, with a major presentation on the subject being given in June at WordCamp Europe 2015 by Zeev Suraski. Matt Mullenweg also fielded questions regarding backwards compatibility and PHP during a Q&A at the same event.
Given the solid track record of WordPress in supporting older versions of PHP in core, it’s unlikely that the 5x branch will be dropped any time soon, but the new version certainly does look promising.
Facebook has, of course, made its own contribution to the evolution of PHP in the form of its HipHop Virtual Machine, which promises equally significant performance improvements. There are also some interesting comparisons between their offering and PHP7 starting to emerge.
While core language improvements are definitely gathering pace, the majority of recent developments in the world of PHP have been in terms of culture, tooling, and community. It’s those that we’ll largely focus on for the remainder of this article.
WordPress and PHP
As a WordPress developer, your first port of call in terms of staying up to speed on PHP standards should be the WordPress Coding Standards page.
In contrast to strongly opinionated languages such as Go or Python, PHP is famously laissez-faire in terms of how it can be used. The adoption of a set of commonly agreed best practices is a great way of imposing some order on your day-to-day coding.
Source code is, as developer Jeff Atwood notes, “the ultimate truth” and as a PHP developer it should be a given that you stay familiar with both the Code Reference and the guts of the software itself.
Modern PHP Best Practices
Spurred on by competition from languages such as Python and Ruby – particularly in its Rails incarnation – the world of PHP has modernized considerably in the last decade.
A brief list of areas to keep up-to-speed on includes the following:
- Coding standards: As mentioned earlier, WordPress has its own set of PHP standards, but there are also several alternative guidelines out there in the wild. Regardless of the exact rules selected, the average PHP project these days will insist on some sort of standardization in this respect so it’s a good idea to study some examples and get familiar with them.
- Dependency management: Dependency and package management were long-standing bugbears of PHP developers for many years until the recent emergence of Composer as a relatively standard way of handling libraries and dependencies. If you haven’t already gotten up to speed on Composer, check out tutorials from Lynda.com or Tuts+ to sharpen your chops.
- Version control: By 2015, the use of version control should be a given for any kind of software development and the PHP community is these days largely on board. Development of the language itself takes place via Git – and if you’re still on the fence about using version control, there is no better time than today to learn the basics.
- Development environments: Having some sort of local development setup is pretty much a must at this stage, and PHP developers are increasingly leaning on advanced solutions such as Vagrant to standardize their work across all environments.
- Testing: The testing culture in PHP has historically lagged behind other languages such as Java or Ruby, but it is catching up. WordPress itself, for example, relies heavily on automated testing for development. If this is an area that is new to you, take some time to explore PHPUnit and the basics of implementing testing in WordPress projects.
- Deployment: Deployment has come a long way from the days of slinging around files via FTP. PHP developers are increasingly leveraging tools such as Phing, Capistrano and Deployer to automate all aspects of their deployment processes.
Learning from PHP Frameworks
Frameworks, whether in the form of Zend, CodeIgniter or CakePHP had of course always been available in PHP, but a combination of better marketing, genuine technical innovation and the advantages of a green-field start all combined to make the new kids on the block particularly attractive in recent times.
The last number of years have seen PHP getting back in the game with a new generation of frameworks that seek to take the best from projects such as Rails or Django and implement them in PHP.
There is no shortage of modern PHP frameworks out there but if you’re looking for one to get your teeth into in order to sharpen your skills then look no further than Laravel. Excellent documentation and tutorials make it a solid place to start exploring standard best practices in modern PHP development.
Studying a well put together framework is a great way of keeping your PHP skills sharp and staying in the loop across all aspects of modern approaches to running a project.
We’ve touched on a number of specific resources so far, but there are also a number of excellent general resources out there to help you hone your PHP knowledge. A short list includes: