2013-05-03 17:02:53 +02:00
|
|
|
<?php
|
2013-05-16 03:16:56 +02:00
|
|
|
/**
|
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
2013-05-16 03:57:02 +02:00
|
|
|
* @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
|
|
|
|
2013-05-15 23:29:09 +02:00
|
|
|
// Let PHP take a guess as to the default timezone, if the user hasn't set one:
|
2014-03-17 19:10:47 +01:00
|
|
|
use PHPCI\Logging\LoggerConfig;
|
|
|
|
|
2014-04-10 16:59:24 +02:00
|
|
|
$timezone = ini_get('date.timezone');
|
|
|
|
if (empty($timezone)) {
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
2013-05-15 19:27:13 +02:00
|
|
|
|
2014-05-06 17:44:23 +02:00
|
|
|
$configFile = dirname(__FILE__) . '/PHPCI/config.yml';
|
2014-12-18 10:34:07 +01:00
|
|
|
$configEnv = getenv('phpci_config_file');
|
2015-10-05 13:13:22 +02:00
|
|
|
$usingCustomConfigFile = false;
|
2015-02-26 09:45:42 +01:00
|
|
|
|
|
|
|
if (!empty($configEnv) && file_exists($configEnv)) {
|
2014-12-18 10:34:07 +01:00
|
|
|
$configFile = $configEnv;
|
2015-10-05 13:13:22 +02:00
|
|
|
$usingCustomConfigFile = true;
|
2014-05-06 17:44:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we don't have a config file at all, fail at this point and tell the user to install:
|
|
|
|
if (!file_exists($configFile) && (!defined('PHPCI_IS_CONSOLE') || !PHPCI_IS_CONSOLE)) {
|
2014-12-03 13:33:38 +01:00
|
|
|
$message = 'PHPCI has not yet been installed - Please use the command "./console phpci:install" ';
|
|
|
|
$message .= '(or "php ./console phpci:install" for Windows) to install it.';
|
|
|
|
|
|
|
|
die($message);
|
2013-10-15 15:14:52 +02:00
|
|
|
}
|
2013-05-03 17:02:53 +02:00
|
|
|
|
2014-05-06 17:44:23 +02:00
|
|
|
// If composer has not been run, fail at this point and tell the user to install:
|
2013-10-15 15:14:52 +02:00
|
|
|
if (!file_exists(dirname(__FILE__) . '/vendor/autoload.php') && defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
|
2014-12-03 13:33:38 +01:00
|
|
|
$message = 'Please install PHPCI with "composer install" (or "php composer.phar install"';
|
|
|
|
$message .= ' for Windows) before using console';
|
|
|
|
|
|
|
|
file_put_contents('php://stderr', $message);
|
2013-10-15 15:14:52 +02:00
|
|
|
exit(1);
|
2013-10-07 13:58:15 +02:00
|
|
|
}
|
|
|
|
|
2013-05-15 23:29:09 +02:00
|
|
|
// Load Composer autoloader:
|
2013-10-10 02:01:06 +02:00
|
|
|
require_once(dirname(__FILE__) . '/vendor/autoload.php');
|
2013-05-15 20:37:56 +02:00
|
|
|
|
2015-03-30 08:56:30 +02:00
|
|
|
\PHPCI\ErrorHandler::register();
|
|
|
|
|
2014-05-09 12:47:42 +02:00
|
|
|
if (defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
|
|
|
|
$loggerConfig = LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php");
|
|
|
|
}
|
2014-03-17 19:10:47 +01:00
|
|
|
|
2013-05-15 23:29:09 +02:00
|
|
|
// Load configuration if present:
|
2013-05-23 13:10:01 +02:00
|
|
|
$conf = array();
|
|
|
|
$conf['b8']['app']['namespace'] = 'PHPCI';
|
2013-09-20 08:33:46 +02:00
|
|
|
$conf['b8']['app']['default_controller'] = 'Home';
|
2013-05-23 13:10:01 +02:00
|
|
|
$conf['b8']['view']['path'] = dirname(__FILE__) . '/PHPCI/View/';
|
2015-10-05 13:13:22 +02:00
|
|
|
$conf['using_custom_file'] = $usingCustomConfigFile;
|
2013-05-23 13:10:01 +02:00
|
|
|
|
2014-05-06 17:44:23 +02:00
|
|
|
$config = new b8\Config($conf);
|
2014-05-08 14:16:09 +02:00
|
|
|
|
|
|
|
if (file_exists($configFile)) {
|
|
|
|
$config->loadYaml($configFile);
|
|
|
|
}
|
2013-05-22 17:36:55 +02:00
|
|
|
|
2015-02-09 10:00:42 +01:00
|
|
|
/**
|
|
|
|
* Allow to modify PHPCI configuration without modify versioned code.
|
2015-06-25 16:21:23 +02:00
|
|
|
* Daemons should be killed to apply changes in the file.
|
2015-02-09 10:00:42 +01:00
|
|
|
*
|
|
|
|
* @ticket 781
|
|
|
|
*/
|
|
|
|
$localVarsFile = dirname(__FILE__) . '/local_vars.php';
|
|
|
|
if (is_readable($localVarsFile)) {
|
|
|
|
require_once $localVarsFile;
|
|
|
|
}
|
|
|
|
|
2013-10-10 02:01:06 +02:00
|
|
|
require_once(dirname(__FILE__) . '/vars.php');
|
2014-12-04 11:23:10 +01:00
|
|
|
|
|
|
|
\PHPCI\Helper\Lang::init($config);
|