bnf/di

Dependency injection container with PSR-11 and container-interop/service-provider support

0.1.3 2019-02-09 11:41 UTC

This package is auto-updated.

Last update: 2024-10-21 07:38:58 UTC


README

Scrutinizer Code Quality Build Status Coverage Status

Provides PSR-11 and container-interop/service-provider support.

Installation

$ composer require bnf/di:~0.1.0

Usage

<?php
require 'vendor/autoload.php';

use Bnf\Di\Container;
use Psr\Container\ContainerInterface;
use Interop\Container\ServiceProviderInterface;

$container = new Container([new class implements ServiceProviderInterface {
    public function getFactories(): array
    {
        return [
            stdClass::class => function (ContainerInterface $container): stdClass {
                return new stdClass;
            }
        ];
    }
    public function getExtensions(): array
    {
        return [];
    }
}]);

$class = $container->get(stdClass::class);
var_dump($class);