horat1us/yii2-di-bootstrap

Yii2 DI 容器 Bootstrap

1.1.1 2019-11-27 03:44 UTC

This package is auto-updated.

Last update: 2024-09-16 04:10:31 UTC


README

Build Status codecov

此包提供 Yii2 依赖注入容器的抽象引导。它必须在具有指定配置依赖项的包中扩展。

此包的主要目的是防止无效的容器配置。

安装

使用 packagist.org

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

使用方法

在你的包中实现 DI 引导

<?php

namespace Package;

use Horat1us\Yii\DI;

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

将包引导添加到你的应用程序配置中

<?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
];

许可协议

MIT