[wp-trac] [WordPress Trac] #36335: Next generation: core autoloader proposal

WordPress Trac noreply at wordpress.org
Thu Apr 21 14:43:03 UTC 2016


#36335: Next generation: core autoloader proposal
-----------------------------+-----------------------------
 Reporter:  dnaber-de        |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  General          |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+-----------------------------

Comment (by schlessera):

 I did not want to delve too deep into the dependency/package management
 topic, as I find that this is a completely separate problem to solve from
 autoloading. Having Composer provide both adds to the general confusion,
 as they often get thrown into the same bucket.

 However, what @greg1anderson says is completely true. When you try to load
 two conflicting libraries, you will always have an issue, no matter how
 many autoloaders you throw in-between. They will only obfuscate the real
 issue, and the sooner you get an error message about the conflict, the
 better. PHP can ever know about 1 version of a given class, whether that
 was `include`d or autoloaded...

 However, I want to clarify one technical nuance from the comment above:

 > This problem cannot be solved by implementing your own common
 autoloader. It can only be solved by having a single autoloader for the
 entire application -- e.g. a single composer.json at the root of the
 project, where plugins are added via `composer require`.

 Yes, there needs to be only 1 single autoloader to get rid of this issue.
 However, there can be as many `composer.json` files as you want (1 for
 each dependency). Composer will recursively go through each of them, and
 build up that one true autoloader. So, if you `composer require`  a
 plugin, that plugin's `composer.json` gets parsed and its class
 definitions added to the autoloader automatically.

 (Just want to make sure people are not afraid to have a `composer.json`
 inside of each plugin or theme.)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36335#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list