PHPackages                             codemix/yii2-configloader - 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. codemix/yii2-configloader

ActiveLibrary

codemix/yii2-configloader
=========================

Build configuration arrays from config files and env vars.

0.11.0(5y ago)60123.4k↓32.4%5MITPHPPHP ^7.1.3 || ^8.0CI failing

Since Feb 28Pushed 5y ago12 watchersCompare

[ Source](https://github.com/codemix/yii2-configloader)[ Packagist](https://packagist.org/packages/codemix/yii2-configloader)[ RSS](/packages/codemix-yii2-configloader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (9)Used By (0)

Yii2 Configloader
=================

[](#yii2-configloader)

[![Build Status](https://camo.githubusercontent.com/dbcc12bfe7d49d673b57311c3cc2d5e98ab2141d9c01aa9c27fd29bbfcd18f53/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f636f64656d69782f796969322d636f6e6669676c6f616465722e706e67)](http://travis-ci.org/codemix/yii2-configloader)[![Latest Stable Version](https://camo.githubusercontent.com/398e5db606a183e242ecd21b3aea4fd8e9ca16322127e0b677c204f20d9036b5/68747470733a2f2f706f7365722e707567782e6f72672f636f64656d69782f796969322d636f6e6669676c6f616465722f762f737461626c652e737667)](https://packagist.org/packages/codemix/yii2-configloader)[![Latest Unstable Version](https://camo.githubusercontent.com/ad62d85f8af084281651d29af4dd95e0acb02f7999148b02a5650855b29f27c0/68747470733a2f2f706f7365722e707567782e6f72672f636f64656d69782f796969322d636f6e6669676c6f616465722f762f756e737461626c652e737667)](https://packagist.org/packages/codemix/yii2-configloader)[![Total Downloads](https://camo.githubusercontent.com/2c0611a5c1197d214707d8a6bab54dc22f54edb600bf8c9770e92f55d11f1c31/68747470733a2f2f706f7365722e707567782e6f72672f636f64656d69782f796969322d636f6e6669676c6f616465722f646f776e6c6f616473)](https://packagist.org/packages/codemix/yii2-configloader)[![License](https://camo.githubusercontent.com/e2585862d74ca68e4491bfba35bcf91ef7e659d9827a5daf5767ccea71125001/68747470733a2f2f706f7365722e707567782e6f72672f636f64656d69782f796969322d636f6e6669676c6f616465722f6c6963656e73652e737667)](https://packagist.org/packages/codemix/yii2-configloader)

Build configuration arrays from config files and environment variables.

Features
--------

[](#features)

You can use this extension to solve some or all of the following tasks:

- Build Yii2 configuration arrays for web and console application
- Initialize Yii environment (`YII_DEBUG`, `YII_ENV`) from environment variables
- Load environment variables from a `.env` file
- Get config options from environment variables
- Load local configuration overrides
- Streamline config initialization and Yii 2 bootstrapping

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

[](#installation)

Install the package with [composer](http://getcomposer.org):

```
composer require codemix/yii2-configloader

```

Description
-----------

[](#description)

We mainly use this extension to configure our dockerized yii2 applications. It's [good practice](https://12factor.net/) to build your docker applications in such a way, that the runtime configuration in productive mode happens solely via environment variables.

But during local development we can loosen these strict requirement a little as we sometimes have to add debug options or the like that should not be part of the main configuration. Here the extension helps to override settings with local configuration files that live outside of version control.

You have several options how to use this extension:

1. Use only the Yii environment initialization
2. Use only the configuration loader
3. Use both

We first show how to use the first two options "standalone" and then a third, combined way that includes all features.

### 1. Initializing Yii environment

[](#1-initializing-yii-environment)

This will set the `YII_DEBUG` and `YII_ENV` variables according to the respective environment variables if those are set. It can also load them from a `.env` file.

In debug mode `error_reporting()` will also be set to `E_ALL`.

```
