Download the PHP package furious/container without Composer
On this page you can find all versions of the php package furious/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package container
DI Container
Very simple PSR-11 DI Container for PHP 7.4+
Install:
composer require furious/container
Use:
$container = new Container();
// get
$container->get('key');
// has
$container->has('key');
// put integers
$container->set(1, 100);
$container->put(2, 200); // use set or put
// put string
$container->set('some string', 'some value');
// put array
$container->set('config', [
'debug' => true,
'some key' => 'some value'
]);
// put clojure
// return SomeClass instance
$container->set(SomeClass::class, function (ContainerInterface $container) {
return new SomeClass();
});
// put object
$container->set(SomeAnotherClass::class, new SomeAnotherClass('value', 'value'));
// autowiring
class A
{
public function __construct(B $b)
{
}
}
class B
{
}
$container->get(A::class);
// Factories
class Factory
{
public function __invoke(ContainerInterface $container)
{
return ExampleClass(
$container->get('key'),
$container->get('key'),
$container->get('key'),
$container->get('key')
);
}
}
$container->set(ExampleClass::class, function (ContainerInterface $container) {
return (new Factory())($container);
});
// Interfaces
interface SomeInterface
{
}
class SomeClass implements SomeInterface
{
}
$container->get(SomeInterface::class, function (ContainerInterface $container) {
return $container->get(SomeClass::class);
});
All versions of container with dependencies
PHP Build Version
Package Version
The package furious/container contains the following files
Loading the files please wait ....