horat1us/yii2-di-bootstrap

Yii2 DI Container Bootstrap

1.1.1 2019-11-27 03:44 UTC

This package is auto-updated.

Last update: 2024-04-16 03:05:58 UTC


README

Build Status codecov

This package provides abstract bootstrap for Yii2 dependency injection container. It have to be extended in packages with specifying available for configuration dependencies.

Main purpose of this package to prevent invalid container configuration.

Installation

Using packagist.org:

composer require horat1us/yii2-di-bootstrap:^1.1

Usage

Implement DI Bootstrap in your package

<?php

namespace Package;

use Horat1us\Yii\DI;

class Bootstrap extends DI\Bootstrap
{
    public function getDefinitions() : array{
        return [
            Package\ConfigInterface::class => Package\Config::class,
        ];
    }
}

Append package Bootstrap to your application configuration

<?php
// config.php

use Package;

return [
    'bootstrap' => [
        'package' => [
            'class' => Package\Bootstrap::class,
            'definitions' => [
                // here you can reconfigure config interface
                // note: another class names can not be configured here
            ],
        ],
    ],
    // ... another application configuration
];

License

MIT