kiwi-suite/servicemanager

kiwi-suite/servicemanager is a psr-11 container library

0.0.1 2017-09-19 20:39 UTC

README

This is a draft. Don't use in production

kiwi-suite/servicemanager

kiwi-suite/servicemanager is a psr-11 container library

Build Status Coverage Status SensioLabsInsight Packagist Packagist Pre Release Packagist

Installation

The suggested installation method is via composer:

php composer.phar require kiwi-suite/servicemanager

About kiwi-suite/servicemanager

kiwi-suite/servicemanager is built on top of zendframework/zend-servicemanager. Like zend-servicemanager it is a factory based approach.

Example

$configurator = new ServiceManagerConfigurator();
$configurator->addFactory(SomeObject::class);
$configurator->addFactory(AnotherObject::class, AnotherObjectFactory::class);
$configurator->addLazyService(SomeObject::class);
$serviceManager = new ServiceManager($configurator->getServiceManagerConfig(), new ServiceManagerSetup());

$serviceManager->get(SomeObject::class);
$serviceManager->build(AnotherObject::class);

Factories

A factory is any class that implements the interface KiwiSuite\ServiceManager\FactoryInterface.

class SomeObjectFactory implements FactoryInterface
{
    public function __invoke(ServiceManagerInterface $container, $requestedName, array $options = null)
    {
        return new SomeObject();
    }
}

$configurator = new ServiceManagerConfigurator();
$configurator->addFactory(SomeObject::class, SomeObjectFactory::class);
$serviceManager = new ServiceManager($configurator->getServiceManagerConfig(), new ServiceManagerSetup());

$serviceManager->get(SomeObject::class);

License

kiwi-suite/servicemanager is open-sourced software licensed under the MIT license - see the LICENSE file for details