decodelabs / wellspring
PHP autoload management tools
Installs: 7 214
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
Requires (Dev)
- decodelabs/phpstan-decodelabs: ^0.6.7
This package is auto-updated.
Last update: 2024-11-04 22:01:17 UTC
README
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.