nerd-framework / nerd-container
This package is abandoned and no longer maintained.
No replacement package was suggested.
There is no license information available for the latest version (v1.0.4) of this package.
Lightweight IoC container with dependency injection
v1.0.4
2016-11-25 14:00 UTC
Requires
- php: >=5.6
- nerd-framework/nerd-contracts: dev-master
Requires (Dev)
- phpunit/phpunit: ~5.3
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: 2.*
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-11 07:15:15 UTC
README
Container with Dependency Injection for Nerd Framework.
Get the container:
$container = new \Nerd\Framework\Container\Container();
Bind class constructor:
$container->bind('foo', Foo::class);
Bind callable factory:
$container->bind('factory', function () { return new Factory(); });
Bind singleton:
$container->singleton('single', SingletonService::class);
Retrieve resources from container:
$foo = $container->get('foo');
Invoke function, class method or class constructor with dependency injection:
$result = $container->invoke(function (FooFactoryInterface $factory) { // $foo will be injected using parameter name // $other will be injected using Bar type hint return $factory->makeFoo(); });
Pass additional resources into invoke() method:
$result = $container->invoke(function ($foo, $a, $b) { // }, ["a" => "Hello", "b" => "World"]);
Resource resolver
Not documented yet.