kiwi-suite/servicemanager

IXOCREATE Servicemanager 库

1.0.0 2021-02-01 14:40 UTC

This package is not auto-updated.

Last update: 2024-09-15 01:22:11 UTC


README

Build Status Coverage Status Packagist PHP Version License

IXOCREATE Servicemanager 是一个使用 laminas/laminas-servicemanager 的 PSR 11 容器库。

安装

通过 composer 安装此包

composer require ixocreate/servicemanager

测试

composer install --dev
phpunit

用法

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

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

工厂

任何实现了 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->serviceManagerConfig(), new ServiceManagerSetup());

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

文档

通过阅读IXOCREATE的文档了解更多。

变更日志

有关最近更改的信息,请参阅CHANGELOG

安全漏洞

如果您发现安全漏洞,请通过电子邮件直接向 opensource@ixocreate.com 报告问题。

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅LICENSE