elazar/auryn-configuration

Modularized configurations for the Auryn dependency injector

1.0.0 2016-06-26 00:46 UTC

This package is auto-updated.

Last update: 2024-10-29 04:59:11 UTC


README

Build Status

Modularized configurations for the Auryn dependency injector

License

This library is licensed under the MIT License.

Installation

Use composer.

composer require elazar/auryn-configuration

Usage

Individual configurations are defined like so:

use Auryn\Injector;
use Elazar\Auryn\Configuration\ConfigurationInterface;

class FooConfiguration implements ConfigurationInterface
{
    public function __invoke(Injector $injector)
    {
        // ...
    }
}

These configurations can be grouped into reusable sets like so:

use Elazar\Auryn\Configuration\ConfigurationSet;

class AcmeConfigurationSet extends ConfigurationSet
{
    public function __construct()
    {
        parent::__construct([
            FooConfiguration::class,
            BarConfiguration::class,
            // ...
        ]);
    }
}

Individual configurations and configuration sets are applied to injectors in the same way:

$injector = new Injector;

$configuration = $injector->make(FooConfiguration::class);
$configuration($injector);

$set = $injector->make(AcmeConfigurationSet::clss);
$set($injector);

Development

To run the PHPUnit test suite:

composer run-script test