dev-master
9999999-devSimple PHP DI Container.
GPL-3.0-or-later
The Requires
The Development Requires
by Deivi Peña
Simple PHP DI Container.
Simple PHP DI Container., (*2)
composer require amber/container
use Amber\Container\Container; $container = new Container();
bind(string $key, mixed $value) : boolean, (*3)
param string $key The unique item's key., (*4)
param mixed $value The value of the item., (*5)
return bool True on success. False if key already exists., (*6)
Bind an Service to the container by a unique key., (*7)
$container->bind($key, $value);
Or bind a class like this., (*8)
$container->bind($class);
get(string $key): mixed, (*9)
param string $key *The unique item's key., (*10)
return mixed The value of the item., (*11)
$container->get($key);
has(string $key): bool param string $key *The unique item's key. return bool, (*12)
$container->has($key);
unbind(string $key): bool, (*13)
param string $key *The unique item's key., (*14)
return bool true on success, false on failure., (*15)
$container->unbind($key);
$container->bindMultiple([$key => $value]);
$container->getMultiple($keys);
$container->unbindMultiple($keys);
make(string $class): mixed, (*16)
param string $class The item's class., (*17)
return mixed The value of the item., (*18)
$container->make($class);
register(string $class, string $alias = null): ServiceClass, (*19)
param string $class The item's class., (*20)
param string $alias The item's alias., (*21)
return ServiceClass, (*22)
$container->register($class);
singleton(string $class, string $alias = null): ServiceClass, (*23)
param string $class The item's class., (*24)
param string $alias The item's alias., (*25)
return ServiceClass, (*26)
$container->singleton($class);
getClosureFor(string $class, string $method, array $binds = []): Closure, (*27)
param string $class The class to instantiate., (*28)
param string $method The class method to call., (*29)
param array $binds The arguments for the service., (*30)
return Closure, (*31)
$container->getClosureFor($class, $method);
More coming soon..., (*32)
Simple PHP DI Container.
GPL-3.0-or-later