...
The methodology I use is including environment file based in PHP like below:
Code Block | ||
---|---|---|
| ||
<?php /* Copyright by Chun Kang (ck@qsok.com) * * @file __env.php * @brief environments for staging and production \n * @author Chun Kang (ck@qsok.com) * * * @notes * 2018.11.13 created * **/ if (! defined('__CK_ENV__')) { // Basic DB Library ------------------------------------------------------------------------------------------------------ define( '__CK__ENV__', 'RUNTIME_ENVIRONMENT_ESTABLISHED'); if (preg_match( "/staging/", getcwd())) // checking if the environment is staging or not by the current working directory { // define include path to load necessary from staging environment set_include_path( ".:/web/staging_server"); } else { set_include_path( ".:/web/production_server"); error_reporting(0); // turn off all error reporting } // End of Basic DB Library ------------------------------------------------------------------------------------------------------ } ?> |
...
Code Block |
---|
include_path = ".;/lib/php/environment" |
Once above is done, you can include __init.php without its detailed path anywhere in your system like below
Code Block |
---|
require_once "__init.php"; |