A flexible dependency injection container based on the modification of
illuminate/container
. - 一个灵活的基于illuminate/container
修改的依赖注入容器。
- PHP >= 5.6
$ composer require guanguans/di -vvv
<?php
require __DIR__.'/vendor/autoload.php';
class ConcreteStub{}
$container = new \Guanguans\Di\Container();
// Simple Bindings
$container->bind(ConcreteStub::class, function ($container) {
return new ConcreteStub();
});
// Binding A Singleton
$container->singleton('ConcreteStub', function ($container) {
return new ConcreteStub();
});
// Binding Interfaces To Implementations
$container->bind(
'App\Contracts\EventPusher',
'App\Services\RedisEventPusher'
);
// Resolving
$concreteStub = $container->make(ConcreteStub::class);
$ composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.