Download the PHP package mougrim/yii2-container-configurator without Composer
On this page you can find all versions of the php package mougrim/yii2-container-configurator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mougrim/yii2-container-configurator
More information about mougrim/yii2-container-configurator
Files in mougrim/yii2-container-configurator
Package yii2-container-configurator
Short Description Yii2 container configurator
License MIT
Homepage https://github.com/mougrim/yii2-container-configurator
Informations about the package yii2-container-configurator
Repository is archived
If you want to maintain it, you can make a fork.
Container configurator Extension for Yii 2
This extension can configure di container for yii2 with simple php-array and use lazy load.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require
section of your composer.json.
Edit file config/main.php:
And create config/container.php:
Usage
Callback
You can use callbacks in container config:
This callback will call in all get:
Services
By default components created as service, i.e. created once in first get:
Prototypes
If you want for every get created new instance, you can use prototype:
Aliases
If you want add alias of service or prototype:
Now this:
equivalent this:
Arguments format
Argument type reference
If you want inject from di, you can use parameter type reference:
Argument type value
If you want inject some value, you can use parameter type value:
Pass arguments to constructor
If you want pass arguments to constructor, you can use 'arguments':
SiteController:
And add to controller map in config/main.php:
Set properties
If you want set properties, you can use 'properties':
Call callback
If you want call callbacks, you can use 'call', but in yii objects (extends from \yii\base\Object) callback will call after method init:
Extends
If you want extend config, you can use 'extends':