rwillians/simple-di

Simple - a simple PHP7 DI alternative to Pimple

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

This package is not auto-updated.

Last update: 2024-04-27 17:26:14 UTC


README

Simple PHP7 DI container.

Usage

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)