laravel-bridge/container

PSR-11 容器桥接器

v1.1.0 2020-03-11 07:04 UTC

This package is auto-updated.

Last update: 2024-09-11 17:59:04 UTC


README

Build Status codecov Codacy Badge Latest Stable Version Total Downloads License

PSR-11 容器桥接器。

Pimple 容器接口桥接到其他容器

构建包装器。

// Laravel Container
$actualContainer = new \Illuminate\Container\Container();
$actualContainer->instance('foo', 'foo');

$wrapper = new \LaravelBridge\Container\Pimple\ContainerWrapper();
$wrapper->setContainer($actualContainer);

// Use like the Pimple Container, but it will register on Laravel Container
$wrapper['bar'] = function($c) {
    return 'bar' . $c->get('foo');
};

$wrapper->get('bar'); // 'barfoo'
$actualContainer->make('bar'); // 'barfoo'

使用 ServiceProvider 桥接器

// Laravel Container
$actualContainer = new \Illuminate\Container\Container();

$bridge = new \LaravelBridge\Container\Pimple\ServiceProviderBridge($actualContainer);

$bridge->register(new YourPimpleServiceProvider());

许可证

MIT 许可证 (MIT)。更多信息请参阅 许可证文件