Search by

nerd-framework / nerd-container

pldin601

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

Package info

github.com/nerd-framework/nerd-container

pkg:composer/nerd-framework/nerd-container

Statistics

Installs: 81

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.4 2016-11-25 14:00 UTC

This package is not auto-updated.

Last update: 2026-10-11 07:15:15 UTC


README

Build Status Coverage Status StyleCI

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.