ixocreate/servicemanager

IXOCREATE Servicemanager 库

1.0.0 2021-02-01 14:40 UTC

This package is auto-updated.

Last update: 2024-09-05 17:57:52 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