[wp-trac] [WordPress Trac] #36335: Next generation: core autoloader proposal
WordPress Trac
noreply at wordpress.org
Mon Jun 6 15:41:51 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: 2nd-opinion | Focuses:
-----------------------------+-----------------------------
Comment (by DvanKooten):
Replying to [comment:45 boonebgorges]:
> A Composer-generated classmap seems like the right way forward here. I
don't see why we should reinvent the wheel, even if it only takes 47 lines
to do it.
This.
I'm strongly in favor of using Composer for autoloading as the main
argument against it seems to be that we should be taking baby steps.
Using Composer just for autoloading for now seems to be the right baby
step for me. It's not introducing any changes to WordPress its public API
_and_ will work just for WP's core classes (what seems to be the goal
here). It will also make things easier for real Composer support in the
future (I dream of this day every single night).
The following example composer.json file scans wp-includes/ and wp-admin/
for classes and then dumps a PHP 5.2 compatible autoloader. It then copies
the generated files to wp-includes/autoloader.
{{{
{
"autoload": {
"classmap": [
"wp-includes/",
"wp-admin/"
]
},
"require": {
"php": ">=5.2.14",
"xrstf/composer-php52": "1.*"
},
"scripts": {
"post-install-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-update-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-autoload-dump": [
"xrstf\\Composer52\\Generator::onPostInstallCmd",
"rm -rf wp-includes/autoloader && cp -r vendor wp-
includes/autoloader"
]
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36335#comment:51>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list