PHPackages                             sergeymakinen/yii2-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sergeymakinen/yii2-config

AbandonedArchivedYii2-extension[Parsing &amp; Serialization](/categories/parsing)

sergeymakinen/yii2-config
=========================

Versatile config loader for Yii 2

v2.1.0(8y ago)132[1 issues](https://github.com/sergeymakinen/yii2-config/issues)MITPHP

Since Dec 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sergeymakinen/yii2-config)[ Packagist](https://packagist.org/packages/sergeymakinen/yii2-config)[ Docs](https://github.com/sergeymakinen/yii2-config)[ RSS](/packages/sergeymakinen-yii2-config/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Yii 2 config loader
===================

[](#yii-2-config-loader)

Versatile config loader for Yii 2. You can define a single config definition file in your favorite language which will define a configuration for all your application tiers (`console`, `backend`, `frontend`, etc).

[![Code Quality](https://camo.githubusercontent.com/e0f88b9345b8ae11251cbb1a6599556f9b7d8a8cd973986447ffb7ca7911bae5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7365726765796d616b696e656e2f796969322d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sergeymakinen/yii2-config) [![Build Status](https://camo.githubusercontent.com/c06f7b3ab2cafeae7e10b7f09c0625858c5aca73297f8056903e4c4ee0e445e0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7365726765796d616b696e656e2f796969322d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/sergeymakinen/yii2-config) [![Code Coverage](https://camo.githubusercontent.com/5c6b8852f5186c5e2c8a96fcdaa1f7fa4ed2f1c229183542493af4d04c99ef5f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f7365726765796d616b696e656e2f796969322d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/sergeymakinen/yii2-config) [![SensioLabsInsight](https://camo.githubusercontent.com/38feaf77c2326529fb7a6a8f538a23ec6ea8b2acf9ee1b502085e16350407aa7/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f62623530663262652d373130382d343932332d393932652d6234656536333666303235322e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/bb50f2be-7108-4923-992e-b4ee636f0252)

[![Packagist Version](https://camo.githubusercontent.com/e5cca8a5438ff3dae4d3d1d589c794216aff15d92dd5f87f04ba59e4ba842801/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7365726765796d616b696e656e2f796969322d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sergeymakinen/yii2-config) [![Total Downloads](https://camo.githubusercontent.com/5915151118d374d9efc80850d60bff96633aa6bacadd21c0a729408984680665/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7365726765796d616b696e656e2f796969322d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sergeymakinen/yii2-config) [![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Example config](#example-config)
- [Shortcuts](#shortcuts)
- [Supported config formats](#supported-config-formats)
    - [INI](#ini)
    - [JSON](#json)
    - [PHP array](#php-array)
    - [PHP bootstrap](#php-bootstrap)
    - [YAML](#yaml)
- [Extending](#extending)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
composer require "sergeymakinen/yii2-config:^2.0"
```

or add

```
"sergeymakinen/yii2-config": "^2.0"
```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

First you need to define your config: it may be a PHP array right in the file you plan to include it in but it's better to place it in a file which can be in any [supported format](#supported-config-formats). Just like it's done in the [example](#example-config).

Then your entry scripts have to be modified to load the config. It's how it can look like for a `console` tier [`yii` file](docs/examples/basic/yii) (consider a *tier* as a *type*) in a Yii 2 [basic project template](https://github.com/yiisoft/yii2-app-basic):

```
#!/usr/bin/env php
