lessname/locator

This package is abandoned and no longer maintained. No replacement package was suggested.

Service locator

3.1.0 2020-03-28 09:01 UTC

This package is auto-updated.

Last update: 2021-11-27 13:29:46 UTC


README

Locate your services

License

Mozilla Public License 2.0

Examples

<?php
use LessLocator\Builder\ResolverLocatorBuilder;
use LessLocator\Config\ArrayConfig;

$config = new ArrayConfig(
    [
        'services' => [
            'initiators' => [
                // value is called with new
                stdClass::class => stdClass::class,
            ],
            'factories' => [
                // A factory is used to create the instance
            ],
            'aliases' => [
                // the value is an other name to use
            ],
            'map' => [
                // value is returned directly
            ],
        ],
    ]
);

$locator = ResolverLocatorBuilder::fromConfig($config);

$locator->getService(stdClass::class); // stdClass instance