2017 © Pedro Peláez
 

yii2-extension yii2-simple-container-configurator

Simple extension for register Yii2 class definition

image

mertvetsky/yii2-simple-container-configurator

Simple extension for register Yii2 class definition

  • Sunday, September 11, 2016
  • by mertvetsky
  • Repository
  • 2 Watchers
  • 1 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

yii2-simple-container-configurator

Just add to config components block, (*1)

        'containerConfig' => [
             'class' => \mertvetsky\yii2SimpleContainerConfigurator\SimpleContainerConfig::class,
             'file' => __DIR__ . '/services.php',
        ],

and 'containerConfig' to bootstrap block., (*2)

Then create config/services.php file with your services definitions like, (*3)

<?php

return [
    'smth' => [
        'class'     => \app\lib\smth\Smth::class,
        'singleton' => false,
        'message'   => 'from config' // or any defined as public field in your class
    ],
    'pew'  => [
        'class' => \app\lib\smth\Pewpew::class
    ]
];

After that you can use your configured classes at any \yii\base\Component child class, (*4)

    public function __construct($id, Module $module, Smth $smth, Pewpew $pewpew, array $config = [])
    {
        parent::__construct($id, $module, $config);
        $this->smth = $smth;
        $this->pewpew = $pewpew;
    }

The Versions

11/09 2016

dev-master

9999999-dev

Simple extension for register Yii2 class definition

  Sources   Download

MIT

The Requires

 

by Avatar mertvetsky

configuration yii2

11/09 2016

0.1

0.1.0.0

Simple extension for register Yii2 class definition

  Sources   Download

MIT

The Requires

 

by Avatar mertvetsky

configuration yii2