[wp-trac] [WordPress Trac] #21300: Implement autoloader compatible with PSR-0 for plugins and themes
WordPress Trac
wp-trac at lists.automattic.com
Wed Jul 18 09:42:34 UTC 2012
#21300: Implement autoloader compatible with PSR-0 for plugins and themes
-----------------------------+------------------------------
Reporter: dave1010 | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: |
-----------------------------+------------------------------
Comment (by dave1010):
At first I had hoped that core classes could be made compatible too but a
quick grep shows around 200 classes in a clean WP install, with fairly
inconsistent naming (https://gist.github.com/3135160). A long-term future
issue may be to try to clean these up (WordPress 4.0?). An autoloader just
for plugins and themes would still be great and encourage consistency.
Though SPL can be disabled, I believe spl_autoload_register is standard
from PHP 5.1.2. I haven't seen any installations without it. Are there any
other extensions (apart from mysql) that could be disabled that WordPress
requires?
If SPL is likely to be disabled then the code could be wrapped in a
`function_exists()`. Alternatively the autoloader could only be ran if PHP
>= 5.3.0 (and include support for namespaces). Plugins and themes that
would like to use a PSR-0 autoloader are quite likely to only support PHP
5.3 anyway. This does, however, introduce a big difference between 5.2 and
5.3, which will make testing problematic.
I still believe this is a great benefit we can give to users running PHP
5.3+ that is worth the disadvantage of the code diverging.
For reference, here's discussion on PSR-0 being implemented in
[http://dev.kohanaframework.org/issues/4001 Kohana] and
[http://drupal.org/node/1240138 Drupal].
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21300#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list