Enable using PSR-4 autoloader for MediaWiki core and extensions
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 24 Aug 2017 18:05:26 +0000 (11:05 -0700)
committerTim Starling <tstarling@wikimedia.org>
Tue, 12 Dec 2017 00:20:11 +0000 (00:20 +0000)
commit036f5b47efc99b56e9e841c8ebdfec7d3e197f83
treef1043446f850f8ff9d760a2658c884b80af34045
parent09112df015428fcbb7f8112677e3b99a17754d0f
Enable using PSR-4 autoloader for MediaWiki core and extensions

This adds support for a PSR-4 (<http://www.php-fig.org/psr/psr-4/>)
autoloader, so instead of needing to manually list each class, just the
namespace prefix is needed.

Extensions can set a "AutoloadNamespaces" property in extension.json to
register PSR-4 compatible namespaces to be autoloaded.

The implementation is based off of the example implementation
(<http://www.php-fig.org/psr/psr-4/examples/>) with some modifications
for performance, notably cutting down on function calls, and only trying
to look up classes that are namespaced.

The generateLocalAutoload.php script will ignore any directory that is
registered as a PSR-4 namespace.

Bug: T99865
Bug: T173799
Change-Id: Id095dde37cbb40aa424fb628bd3c94e684ca2f65
autoload.php
docs/extension.schema.v1.json
docs/extension.schema.v2.json
includes/AutoLoader.php
includes/registration/ExtensionRegistry.php
includes/utils/AutoloadGenerator.php
maintenance/generateLocalAutoload.php
tests/phpunit/structure/AutoLoaderTest.php