Skip to content

[READ ONLY] Factory for PSR-11 compatible DI container and injector. Subtree split of the Zorachka Container component (see zorachka/zorachka)

License

Notifications You must be signed in to change notification settings

zorachka/container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zorachka Container


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.

Latest Version on Packagist Tests Analysis Total Downloads

Installation

You can install the package via composer:

composer require zorachka/container

Usage

To create a container you need to pass array of ServiceProvider objects interface:

<?php

declare(strict_types=1);

use Psr\Container\ContainerInterface;
use Zorachka\Container\ContainerFactory;
use Zorachka\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;
                }
            ];
        }
    }
]);

Testing

make test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

[READ ONLY] Factory for PSR-11 compatible DI container and injector. Subtree split of the Zorachka Container component (see zorachka/zorachka)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages