php-censor/bootstrap.php

70 lines
1.7 KiB
PHP
Raw Normal View History

2013-05-03 17:02:53 +02:00
<?php
2013-05-16 03:16:56 +02:00
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
2013-05-16 03:16:56 +02:00
*/
2013-05-03 17:02:53 +02:00
2016-07-19 20:28:11 +02:00
use PHPCensor\Logging\LoggerConfig;
2016-04-21 19:05:32 +02:00
if (!defined('ROOT_DIR')) {
define('ROOT_DIR', __DIR__ . DIRECTORY_SEPARATOR);
2014-04-10 16:59:24 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('SRC_DIR')) {
define('SRC_DIR', ROOT_DIR . 'src' . DIRECTORY_SEPARATOR . 'PHPCensor' . DIRECTORY_SEPARATOR);
2016-04-21 19:05:32 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('PUBLIC_DIR')) {
define('PUBLIC_DIR', ROOT_DIR . 'public' . DIRECTORY_SEPARATOR);
2016-04-21 19:05:32 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('APP_DIR')) {
define('APP_DIR', ROOT_DIR . 'app' . DIRECTORY_SEPARATOR);
2016-04-21 19:05:32 +02:00
}
2015-02-26 09:45:42 +01:00
2016-07-21 17:20:34 +02:00
if (!defined('BIN_DIR')) {
define('BIN_DIR', ROOT_DIR . 'bin' . DIRECTORY_SEPARATOR);
}
2016-07-21 17:20:34 +02:00
if (!defined('RUNTIME_DIR')) {
define('RUNTIME_DIR', ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR);
}
2013-05-03 17:02:53 +02:00
2016-04-21 19:05:32 +02:00
if (!defined('IS_WIN')) {
define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false));
}
2016-04-21 19:05:32 +02:00
require_once(ROOT_DIR . 'vendor/autoload.php');
2013-05-15 20:37:56 +02:00
2016-07-19 20:28:11 +02:00
\PHPCensor\ErrorHandler::register();
2016-07-21 17:20:34 +02:00
if (defined('IS_CONSOLE') && IS_CONSOLE) {
$loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php");
}
// Load configuration if present:
2016-04-20 12:30:26 +02:00
$conf = [];
2016-07-19 20:28:11 +02:00
$conf['b8']['app']['namespace'] = 'PHPCensor';
$conf['b8']['app']['default_controller'] = 'Home';
2016-07-21 17:20:34 +02:00
$conf['b8']['view']['path'] = SRC_DIR . 'View' . DIRECTORY_SEPARATOR;
$config = new b8\Config($conf);
2016-07-21 17:20:34 +02:00
$configFile = APP_DIR . 'config.yml';
if (file_exists($configFile)) {
$config->loadYaml($configFile);
}
2016-07-21 17:20:34 +02:00
if (!defined('APP_URL') && !empty($config)) {
define('APP_URL', $config->get('phpci.url', '') . '/');
}
2016-07-21 17:20:34 +02:00
if (!defined('IS_CONSOLE')) {
define('IS_CONSOLE', false);
2016-04-21 19:05:32 +02:00
}
2014-12-04 11:23:10 +01:00
2016-07-19 20:28:11 +02:00
\PHPCensor\Helper\Lang::init($config);