public static function bootstrap($approot = null) { static $done = 0; if ($done) { return; } $done = 1; foreach ((array) xenon::config('framework.preload') as $preload) { class_exists($preload, true); } $dm = (int) xenon::config('framework.debuglevel'); if ($dm == 0) { setenv("DEBUG=0"); } if ($dm >= 1) { setenv("DEBUG=1"); } if ($dm >= 2) { setenv("DEBUG_VERBOSE=1"); } $path = getenv("CHERRY_LIB"); require_once $path . '/lib/bootstrap.php'; if (!$approot) { $approot = getcwd(); } else { $approot = realpath($approot); } \Cherry\Base\PathResolver::getInstance()->setAppPath($approot); define("XENON_FWAPI", '\\xenon\\frameworks\\cherryphp'); }
/** * @covers \Phix\App::env */ public function testEnv() { $app = new App(); $this->assertEquals(App::ENV_PRODUCTION, $app->env()); $app->env(null); $_SERVER['PHIX_ENV'] = App::ENV_STAGING; $this->assertEquals(App::ENV_STAGING, $app->env()); unset($_SERVER['PHIX_ENV']); $app->env(null); $this->assertEquals(App::ENV_PRODUCTION, $app->env()); $app->env(null); if (function_exists('setenv') && setenv('PHIX_ENV', App::ENV_TESTING)) { $this->assertEquals(App::ENV_TESTING, $app->env()); setenv('PHIX_ENV', ''); $app->env(null); } $app->env(App::ENV_DEVELOPMENT); $this->assertEquals(App::ENV_DEVELOPMENT, $app->env()); $app->env(null); $ret = $app->env(function () { return 'callback'; }); $this->assertEquals('callback', $app->env()); $this->assertEquals($ret, $app); $app->env(null); }
/** * Import environment file. */ private function importEnvironmentFile() { $envFile = $this->getPath() . '/' . $this->envFile; if (file_exists($envFile)) { $loader = new FileLoader(); $vars = $loader->import(new FileLoader\FileLocator($envFile)); foreach ($vars as $name => $value) { $name = strtolower($name); $this->envs[$name] = $value; setenv($name, $value); } } }