This package provides a factory for PSR-11 compatible
dependency injection container that is able to instantiate
and configure classes resolving dependencies and ServiceProvider
interface.
Uses PHP-DI as a core.
You can install the package via composer:
composer require a50/container
To create a container you need to pass array of ServiceProvider
objects interface:
<?php
declare(strict_types=1);
use Psr\Container\ContainerInterface;
use A50\Container\ContainerFactory;
use A50\Container\ServiceProvider;
$container = ContainerFactory::build([
new class implements ServiceProvider {
/**
* @inheritDoc
*/
public static function getDefinitions(): array
{
return [
stdClass::class => static fn() => new stdClass(),
];
}
/**
* @inheritDoc
*/
public static function getExtensions(): array
{
return [
stdClass::class => static function ($stdClass, ContainerInterface $container): stdClass {
$stdClass->property = 'value';
return $stdClass;
}
];
}
}
]);
make test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.