Wellspring provides simple tools to manage and configure autoloaders in PHP.
Get news and updates on the DecodeLabs blog.
Install via Composer:
composer require decodelabs/wellspring
Use Wellspring
to register autoloaders with a Priority level - the higher the priority, the earlier the autoloader will be called.
The library automatically remaps loaders on the fly when necessary (even when spl_autoload_register()
and spl_autoload_unregister()
are used directly), ensuring edge-case functionality does not interfere with the intended load order.
Any loaders registered without a priority default to Priority::Medium
, and any with matching priorities will be called in the order they were registered.
use DecodeLabs\Wellspring;
use DecodeLabs\Wellspring\Priority;
Wellspring::register(function(string $class) {
// This will get called last
}, Priority::Low);
Wellspring::register(function(string $class) {
// This will get called first
}, Priority::High);
spl_autoload_register(function(string $class) {
// This will get called second
});
spl_autoload_call('test');
Wellspring is licensed under the MIT License. See LICENSE for the full license text.