PHP Namespaces: A Tool For WordPress Plugin Authors?

PHP namespaces
As part of PHP 5.3, namespaces will be a tremendous improvement for framework developers and object oriented programmers. But also for some WordPress plugin authors, namespaces might be a neat instument to easily write non conflictable code.  So instead of having to be creative in naming classes, functions and constants, authors now just have to pick a unique plugin name (as always), declare a namespace for it and can feel free to use whatever function names they like and suits best.

Sounds tempting? There’s just one minor catch to it: Authors can’t assume that the average WordPress user has PHP 5.3 up an running on their system.

So what about backwards compatibility?

There simply is none. Since namespaces are just being introudced, there is no such thing as a fallback for plugins. So authors can either declare their plugins suitable only for users with PHP 5.3 or higher, or write two plugins, to also satisfy all other users.

What is your opinion? Will you use namespaces when developing a new plugin?

Leave a Reply