diff --git a/bootstrap.php b/bootstrap.php index ee819c49..02e8c820 100755 --- a/bootstrap.php +++ b/bootstrap.php @@ -33,10 +33,24 @@ $autoload = function ($class) { spl_autoload_register($autoload, true, true); -if (!file_exists(dirname(__FILE__) . '/PHPCI/config.yml') && (!defined('PHPCI_IS_CONSOLE') || !PHPCI_IS_CONSOLE)) { +// If the PHPCI config file is not where we expect it, try looking in +// env for an alternative config path. +$configFile = dirname(__FILE__) . '/PHPCI/config.yml'; + +if (!file_exists($configFile)) { + $configEnv = getenv('phpci_config_file'); + + if (!empty($configEnv)) { + $configFile = $configEnv; + } +} + +// 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)) { die('PHPCI has not yet been installed - Please use the command ./console phpci:install to install it.'); } +// If composer has not been run, fail at this point and tell the user to install: if (!file_exists(dirname(__FILE__) . '/vendor/autoload.php') && defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) { file_put_contents('php://stderr', 'Please install PHPCI with "composer install" before using console'); exit(1); @@ -54,9 +68,7 @@ $conf['b8']['app']['namespace'] = 'PHPCI'; $conf['b8']['app']['default_controller'] = 'Home'; $conf['b8']['view']['path'] = dirname(__FILE__) . '/PHPCI/View/'; -if (file_exists(dirname(__FILE__) . '/PHPCI/config.yml')) { - $config = new b8\Config($conf); - $config->loadYaml(dirname(__FILE__) . '/PHPCI/config.yml'); -} +$config = new b8\Config($conf); +$config->loadYaml($configFile); require_once(dirname(__FILE__) . '/vars.php');