Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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');

date_default_timezone_set('Asia/Seoul');

	if (preg_match( "/staging/", getcwd())) // checking if the environment is staging or not by the current working directory
	{
define( '__NEWID_BASE_DIR__', '/pub/staging');
define( '__NEWID_DOMAIN_NAME__', 'stg.its-newid.net');
		// define include path to load necessary from staging environment
		set_include_path( ".:/pub/staging:/pubweb/staging/_libserver");
	}
	else
{
define( '__NEWID_BASE_DIR__', '/pub/production');
define( '__NEWID_DOMAIN_NAME__', 'its-newid.net');
	{
		set_include_path( ".:/pub/production:/pubweb/production/_libserver");

		error_reporting(0); // turn off all error reporting
}

$NEWID_BASE_DIR = __NEWID_BASE_DIR__;
$NEWID_DOMAIN_NAME = __NEWID_DOMAIN_NAME__;	}

// End of Basic DB Library ------------------------------------------------------------------------------------------------------
}

?>

Note set_include_path() will help you to include necessary modules by relative path easily, so you don't need to worry about remembering staging / production directory path.


If you want to hide __env.php somewhere in the system, you can simply add that condition to php.ini as following:

Code Block
include_path = ".:/lib/php/environment"

If your environment is Windows, it should be like below:

Code Block
include_path = ".;/lib/php/environment"