rwillians/simple-di

Simple - 一个简单的 PHP7 DI,作为 Pimple 的替代方案

v0.1.0-alpha 2016-09-05 02:41 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:31:16 UTC


README

Simple PHP7 DI 容器。

使用方法

use Rwillians\SimpleDI\Container;
use Rwillians\SimpleDI\Contracts\ServiceLocatorInterface;

$container = new Container([
    'foo' => 'bar',
    'bar' => 'baz',
    'baz' => 10,
]);

$container->set('awsome.number', function (ServiceLocatorInterface $serviceLocator) {
    return $serviceLocator->get('baz') + 5;
});

echo $container->resolve('awsome.number'); // Outputs 15 (10 + 5)