Download the PHP package shadowhand/cairon without Composer
On this page you can find all versions of the php package shadowhand/cairon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shadowhand/cairon
More information about shadowhand/cairon
Files in shadowhand/cairon
Package cairon
Short Description Configuration wrapper for auryn dependency injector
License MIT
Informations about the package cairon
cairon
A tiny wrapper around an auryn that provides configuration capabilities. Attempts to be PSR-1, PSR-2, and PSR-4 compliant.
Usage
The basic purpose of cairon is to apply callable configurations to auryn.
This is done using either configure()
with a list of callables, or apply()
with a single callable.
Callables
The only requirement for the callable is that it accept an instance
of Auryn\Injector
as the first and only argument:
Note: If the provided configuration is not currently callable, it is assumed
to be a class name and will be resolved by calling Injector::make()
.
Best Practice
The preferred approach to using cairon is by creating a closure that is included. This removes the need to create a concrete class for configuration and promotes the idea that auryn is only used in bootstrapping.
For example, we could create config/injection/psr7.php
:
And then apply it in our bootstrap:
Existing Injector
If you already have an instance of Auryn\Injector
it can be provided to the constructor:
Inspiration
The theory behind cairon comes from elazar/auryn-configuration. This same theory was also adopted by equip/config. My goal was to simplify the theory into a wrapper that could be used with any callable, without implementing a concrete interface.
License
MIT.