PHP Namespaces in WordPress

Namespaces are a feature that was introduced in 2009 as part of PHP 5.3. As of this writing, the current version of PHP is 5.6.13, and the anticipated release of PHP 7.0 is rapidly approaching. So why aren’t WordPress theme and plugin developers using namespaces to organize their code? Our colleagues in other PHP projects have moved forward – like Laravel, Drupal, Zend Framework. Some will blame WordPress core, due to their continued support of PHP 5.2. This won’t change until significant numbers of users have upgraded to a higher version of PHP. That shouldn’t prevent plugin authors from pushing forward though. In fact, if plugin authors were to include features from newer versions of PHP, it would prompt users/customers/bloggers/designesr/etc, to update their websites. I admit I haven’t been the best about this either – but that’s gonna change. Perhaps this happens because people get comfortable with a particular way of doing things. Maybe they think that since WordPress Core hasn’t changed their minimum supported version, that they too are bound by it. But they would be wrong. I now think it’s our responsibility to push things forwrard.

Are you holding back your PHP development by staying lock-step with core? Look at the PHP changelog for all the improvements and new features that have been created since 5.2. Then ask yourself how you can use implement these features.

* Migrating from PHP 5.2.x to PHP 5.3.x
* Migrating from PHP 5.3.x to PHP 5.4.x
* Migrating from PHP 5.4.x to PHP 5.5.x
* Migrating from PHP 5.5.x to PHP 5.6.x

Namespaces is only the beginning of what’s possible in newer PHP versions. Push the web forward.

Sorry, but comments are closed. I hope you enjoyed the article