thecodingmachine/yaco-service-provider

此包是container-intop的服务提供者与YACO(PSR-11兼容的容器编译器)之间的桥梁。

1.0.x-dev 2016-04-11 14:49 UTC

This package is auto-updated.

Last update: 2024-09-15 04:36:54 UTC


README

Scrutinizer Code Quality Build Status Coverage Status

container-interop的服务提供者与YACO之间的桥梁

此包是container-interop的服务提供者YACO,PSR-11兼容的容器编译器之间的桥梁。

使用此包,您可以使用Yaco生成包含container-interop的服务提供者所提供服务的PSR-11兼容容器。

安装

composer require thecodingmachine/yaco-service-provider

将服务提供者加载到Yaco中

use TheCodingMachine\Yaco\Compiler;
use TheCodingMachine\Yaco\ServiceProvider\ServiceProviderLoader;

// Create your YACO compiler.
$compiler = new Compiler();

// Create your service provider loader
$serviceProviderLoader = new ServiceProviderLoader($compiler);

// Load service providers into Yaco:
$serviceProviderLoader->load(MyServiceProvider::class);
$serviceProviderLoader->load(MyOtherServiceProvider::class);

// Services are now available in Yaco, we just need to dump the container:
$code = $compiler->compile('MyContainer');
file_put_contents(__DIR__.'/MyContainer.php', $code);

使用Puli自动发现服务提供者

如果您加载的服务提供者在Puli上发布,您可以使用Puli的发现机制轻松加载服务

// The discoverAndLoad function takes a Puli discovery instance in parameter.
// It will discover and load service providers automatically.
$serviceProviderLoader->discoverAndLoad($discovery)