Basically Loads and/or overrides configuration file depending on your environment file. Its basically the conventional cakePHP bootstrap.php file that was extended
Environment options supported are;
- development
- local (for if you are developing locally on your machine)
- production (This is recommended for your live configuration overrides)
theres an additional directory created in
config/that has these environment names. you can create em if it does not exist.
- CakePHP 3
NOTE : If you use local environment on live environment, it automatically sets it to production, providing you must have the same override files in production as is in local. but it is recommended you also set your environment.. while it is also adviceable to set default config to production ready values
Replace your current bootstrap.php with the one in this repo.
Set your environment on line 91
define( 'ENVIRONMENT', 'local' );Open the bootstrap.php file - line 96 , add your configurations file names.
Configuration file names should be without path or .php ext
$configFiles =
[
'defaults' => // this are your original configurations files
[
'app'
],
'overrides' => // this are your environment based configuration to override specific values from the original configuration file
[
// 'app' // you might need to create this first in the desired environment dir
]
];Creates a file named app.php inside config/local/ with the following content
// config/local/app.php
// value to override in default cake config/app.php file
return
[
'debug' => filter_var( env( 'DEBUG', true ), FILTER_VALIDATE_BOOLEAN ), // the debug can be set to false in your defaul app.php file
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => '',
'database' => 'local_test_db',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
'log' => false,
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
'url' => env( 'DATABASE_TEST_URL', null ),
]
]
]Add the file to $configFiles['overrides'] array.
PS: You can override any of your default configurations with your overrides. Read more on cake configurations.
$configFiles =
[
'defaults' =>
[
'app'
],
'overrides' =>
[
'app'
]
];LOL, Just kidding, thats all that neccesary. Neither do I like stressful implementation. Have a wonderful time coding
I would advice you add the content of the .gitignore file to your existing .gitignore file project root or create one. So whenever you push (probably continous deployment), you are sure as h*ll not gonna push your unwanted overrides in production with. That way, atleast you get an error message saying one of your override file can not be loaded.
- GNU GPLV3