<?php

use Cake\Cache\Cache;
use Cake\Core\Configure;
use Josegonzalez\Environments\Environment;
Environment::configure('staging', ['server' => ['staging.example.com']], ['Settings.FULL_BASE_URL' => 'http://staging.example.com', 'Email.username' => '*****@*****.**', 'Email.password' => 'password', 'Email.test' => '*****@*****.**', 'Email.from' => '*****@*****.**', 'logQueries' => true, 'debug' => 0, 'Security.level' => 'medium', 'Security.salt' => 'SALT', 'Security.cipherSeed' => 'CIPHERSEED'], function () {
    date_default_timezone_set('UTC');
    Cache::config('default', ['engine' => 'File']);
    if (!defined('FULL_BASE_URL')) {
        define('FULL_BASE_URL', Configure::read('Settings.FULL_BASE_URL'));
    }
});
<?php

use Cake\Core\Configure;
use Josegonzalez\Environments\Environment;
Environment::configure('development', true, ['Settings.FULL_BASE_URL' => 'http://example.dev', 'Email.username' => '*****@*****.**', 'Email.password' => 'password', 'Email.test' => '*****@*****.**', 'Email.from' => '*****@*****.**', 'logQueries' => true, 'debug' => 2, 'Cache.disable' => true, 'Security.salt' => 'SALT', 'Security.cipherSeed' => 'CIPHERSEED'], function () {
    if (!defined('FULL_BASE_URL')) {
        define('FULL_BASE_URL', Configure::read('Settings.FULL_BASE_URL'));
    }
});
 /**
  * Test whether functions in config works
  */
 public function testStartFunctions()
 {
     Environment::configure('dev2', ['is_bool' => false], [], null);
     Environment::start(null, 'staging');
     $this->assertEquals('dev2', Environment::is());
 }
<?php

use Cake\Cache\Cache;
use Cake\Core\Configure;
use Josegonzalez\Environments\Environment;
Environment::configure('production', ['server' => ['example.com']], ['Settings.FULL_BASE_URL' => 'http://example.com', 'Email.username' => '*****@*****.**', 'Email.password' => 'password', 'Email.test' => '*****@*****.**', 'Email.from' => '*****@*****.**', 'debug' => 0, 'Security.level' => 'medium', 'Security.salt' => 'SALT', 'Security.cipherSeed' => 'CIPHERSEED'], function () {
    error_reporting(0);
    if (function_exists('apc_fetch') && Configure::read('debug') == 0) {
        Cache::config('default', ['engine' => 'Apc', 'duration' => 3600, 'probability' => 100, 'prefix' => 'DEFAULT_']);
        Cache::config('_cake_core_', ['engine' => 'Apc', 'duration' => 3600, 'probability' => 100, 'prefix' => '_cake_core_']);
        // Override the debug_lot cache as not doing so makes some Cache::write() calls use the File cache
        Cache::config('debug_kit', ['engine' => 'Apc', 'duration' => '+4 hours', 'probability' => 100, 'prefix' => 'DEBUG_KIT_']);
        Cache::config('QUERYCACHE', ['engine' => 'Apc', 'duration' => 100, 'probability' => 100, 'prefix' => 'QUERYCACHE_']);
    }
    if (!defined('FULL_BASE_URL')) {
        define('FULL_BASE_URL', Configure::read('Settings.FULL_BASE_URL'));
    }
});
 /**
  * Kicks off the environment setup
  *
  * @param string $environment Name of the environment we want to force setup for
  * @param string $default Default environment name
  * @return bool
  **/
 public static function start($environment = null, $default = 'development')
 {
     $_this = Environment::getInstance();
     return $_this->setup($environment, $default);
 }
<?php

use Josegonzalez\Environments\Environment;
include dirname(__FILE__) . DS . 'environments' . DS . 'production.php';
include dirname(__FILE__) . DS . 'environments' . DS . 'staging.php';
include dirname(__FILE__) . DS . 'environments' . DS . 'development.php';
// run
Environment::start();