Lightweight PHP IoC container, follow PSR-11
- Auto-wiring
- Dependency resolution
- Service Provider
composer require xiaker/gourd
$container = new Xiaker\Gourd\Container;
$container->set(User::class, function () {
return new User();
});
$container->set('logger', Logger::class);
$user = $container->get(User::class);
...
$logger = $container->get('logger');
...
$logger2 = $container['logger'];
...
see test case