Skip to content

decodelabs/wellspring

Repository files navigation

Wellspring

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

PHP autoload management tools

Wellspring provides simple tools to manage and configure autoloaders in PHP.

Get news and updates on the DecodeLabs blog.


Installation

Install via Composer:

composer require decodelabs/wellspring

Usage

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');

Licensing

Wellspring is licensed under the MIT License. See LICENSE for the full license text.

About

PHP autoload management tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages