You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require guenbakku/cakeenv
Open and modify file config/bootstrap.php
like following:
Before:
try {
Configure::config('default', new PhpConfig());
Configure::load('app', 'default', false);
} catch (\Exception $e) {
exit($e->getMessage() . "\n");
}
After:
try {
Configure::config('default', new PhpConfig());
Plugin::load('Guenbakku/Cakeenv', ['bootstrap' => false, 'routes' => false]);
Guenbakku\Cakeenv\Environment::load('app', 'default', false);
} catch (\Exception $e) {
exit($e->getMessage() . "\n");
}
Note:
Name of each environment directory can be set to anything you want.
config
|--- environments
|--- development
|--- app.php
|--- production
|--- app.php
|--- stagging
|--- app.php
|--- env
Open file config/environments/env
, set environment name you want in the first line and save it. That's all.
Example:
development
Note:
Following is the memo for developing this plugin. End-user can skip this section.
# 1. Build docker image for developing (first time only)
$ docker-compose build
# 2. Composer installing (first time only)
$ docker-compose run --rm php composer install
# 3. Execute phpunit
$ docker-compose run --rm php vendor/bin/phpunit