devilbox/.devilbox/www/config.php

97 lines
2.2 KiB
PHP
Raw Normal View History

2016-10-09 16:47:49 +00:00
<?PHP
2016-11-06 12:36:07 +00:00
// Measure time
$TIME_START = microtime(true);
2016-10-09 16:47:49 +00:00
2016-11-06 12:36:07 +00:00
// PHP Error reporting
error_reporting(-1);
2016-10-09 16:47:49 +00:00
2016-11-06 12:36:07 +00:00
//
// Set Directories
//
$CONF_DIR = dirname(__FILE__);
$INCL_DIR = $CONF_DIR . DIRECTORY_SEPARATOR . 'include';
$LIB_DIR = $INCL_DIR . DIRECTORY_SEPARATOR . 'lib';
2016-11-06 16:20:51 +00:00
$VEN_DIR = $INCL_DIR . DIRECTORY_SEPARATOR . 'vendor';
2016-11-06 12:36:07 +00:00
$LOG_DIR = dirname(dirname($CONF_DIR)) . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'devilbox';
2016-10-09 16:47:49 +00:00
/**
* TLD suffix for mass virtual hosts.
*
* This is currently hardcoded and must be changed here
* as well as in the webserver config.
* @var string
*/
$TLD_SUFFIX = 'loc';
2016-11-06 12:36:07 +00:00
//
// Set Docker addresses
//
2016-10-09 16:47:49 +00:00
$HTTPD_HOST_NAME = 'httpd';
$HTTPD_HOST_ADDR = gethostbyname($HTTPD_HOST_NAME);
2016-11-06 12:36:07 +00:00
$PHP_HOST_NAME = 'php';
$PHP_HOST_ADDR = gethostbyname($PHP_HOST_NAME);
2016-10-09 16:47:49 +00:00
2016-11-15 18:39:34 +00:00
$MYSQL_HOST_NAME = 'mysql';
2016-10-09 16:47:49 +00:00
$MYSQL_HOST_ADDR = gethostbyname($MYSQL_HOST_NAME);
2016-11-15 18:39:34 +00:00
$POSTGRES_HOST_NAME = 'postgres';
$POSTGRES_HOST_ADDR = gethostbyname($POSTGRES_HOST_NAME);
2016-11-06 12:36:07 +00:00
//
2017-04-19 17:48:44 +00:00
// Lazy Loader
2016-11-06 12:36:07 +00:00
//
2017-04-19 17:48:44 +00:00
function loadClass($class) {
global $LIB_DIR;
global $MYSQL_HOST_ADDR;
global $POSTGRES_HOST_ADDR;
static $_LOADED_LIBS;
if (isset($_LOADED_LIBS[$class])) {
return $_LOADED_LIBS[$class];
} else {
switch($class) {
case 'Logger':
require $LIB_DIR . DIRECTORY_SEPARATOR . $class . '.php';
$_LOADED_LIBS[$class] = \devilbox\Logger::getInstance();
break;
case 'Docker':
require $LIB_DIR . DIRECTORY_SEPARATOR . $class . '.php';
$_LOADED_LIBS[$class] = \devilbox\Docker::getInstance();
break;
case 'Mysql':
require $LIB_DIR . DIRECTORY_SEPARATOR . $class . '.php';
$Docker = loadClass('Docker');
$_LOADED_LIBS[$class] = \devilbox\Mysql::getInstance('root', $Docker->getEnv('MYSQL_ROOT_PASSWORD'), $MYSQL_HOST_ADDR);
break;
case 'Postgres':
require $LIB_DIR . DIRECTORY_SEPARATOR . $class . '.php';
$Docker = loadClass('Docker');
$_LOADED_LIBS[$class] = \devilbox\Postgres::getInstance($Docker->getEnv('POSTGRES_USER'), $Docker->getEnv('POSTGRES_PASSWORD'), $POSTGRES_HOST_ADDR);
break;
default:
exit('Class does not exist: '.$class);
}
return $_LOADED_LIBS[$class];
}
}
2016-10-09 16:47:49 +00:00
2016-11-06 12:36:07 +00:00
// VirtualHost DNS check
// Temporarily disable due to:
// https://github.com/cytopia/devilbox/issues/8
2016-11-15 18:52:13 +00:00
$ENABLE_VHOST_DNS_CHECK = false;