ixocreate/servicemanager

IXOCREATE Servicemanager

0.1.1 2019-05-06 13:25 UTC

README

Build Status Coverage Status SensioLabsInsight Packagist PHP Version License

IXOCREATE Servicemanager is a PSR 11 container library utilizing zendframework/zend-servicemanager.

Installation

Install the package via composer:

composer require ixocreate/servicemanager

Testing

composer install --dev
phpunit

Usage

$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 Ixocreate\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);

Documentation

Learn more about IXOCREATE by reading its Documentation.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

If you discover security vulnerabilities, please address issues directly to opensource@ixocreate.com via e-mail.

License

The MIT License (MIT). Please see LICENSE for more information.