janisto/yii2-environment Environment class for Yii 2, used to set configuration for console and web apps depending on the server environment.

extensionconfigurationenvironment

Yii 2 Environment

Environment class for Yii 2, used to set configuration for console and web apps depending on the server environment.

Software License Build Status Code Quality Code Coverage Packagist Version Total Downloads

Installation

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install this package using the following command:

php composer.phar require "janisto/yii2-environment" "*"

or add

"janisto/yii2-environment": "*"

to the require section of your application's composer.json file.

Usage

web index.php

<?php
require(dirname(__DIR__) . '/vendor/autoload.php');

$env = new \janisto\environment\Environment(dirname(__DIR__) . '/config');
$env->setup();
(new yii\web\Application($env->web))->run();

or if you have multiple configuration locations

<?php
require(dirname(__DIR__) . '/vendor/autoload.php');

$env = new \janisto\environment\Environment([
    dirname(__DIR__) . '/common/config',
    dirname(__DIR__) . '/backend/config'
]);
$env->setup();
(new yii\web\Application($env->web))->run();

console yii

#!/usr/bin/env php
<?php

require(__DIR__ . '/vendor/autoload.php');

// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));

$env = new \janisto\environment\Environment(__DIR__ . '/config');
$env->setup();
$exitCode = (new yii\console\Application($env->console))->run();
exit($exitCode);

Use yii

export YII_ENV='dev' && ./yii

Documentation

See examples/.

Contributing

Please see CONTRIBUTING for details.

Credits

License

Public domain. Please see License File for more information.

Changelog

Changelog

All Notable changes to yii2-environment will be documented in this file.

1.3.0 - 2016-06-01

Fixed

  • Travis + Scrutinizer

Added

  • Tests

1.2.0 - 2015-06-26

Fixed

  • Updated dependencies
  • Travis

1.1.1 - 2015-04-09

Fixed

  • Bug #2: Use late static bindings with merge

1.1.0 - 2015-04-08

Added

  • Code refactor
  • Added to Travis and Scrutinizer

Fixed

  • Bug #1: Added merge method for easier ArrayHelper override

1.0.1 - 2014-10-27

Added

  • Examples

1.0.0 - 2014-10-27

  • Initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.3.0 is the latest of 6 releases



public domain license
Stats
20 github stars & 5 github forks
2 downloads in the last day
53 downloads in the last 30 days
33573 total downloads