/** * @param string $url * @param \Phalcon\DI\FactoryDefault $di */ private function runApplication($url, DI\FactoryDefault $di = null) { require_once dirname(__DIR__) . '/../fixtures/app/Bootstrap.php'; $config = (require dirname(__DIR__) . '/../fixtures/app/config/config.php'); $config = new \Phalcon\Config($config); $bootstrap = new \Bootstrap($config); if ($di != null) { $bootstrap->setDi($di); } $bootstrap->setup()->run($url); }
public static function run() { Bootstrap::setup(); $app = new App(); if (Util::has_request_param("action")) { $api = new Api($app); $api->apply(); } else { define("FALLBACK", $app->get_fallback()); normalized_require_once("page"); } }
public function setUp() { $_SERVER['HTTP_HOST'] = 'vegas.dev'; $_SERVER['REQUEST_URI'] = '/'; $this->di = DI::getDefault(); $modules = (new ModuleLoader())->dump(TESTS_ROOT_DIR . '/fixtures/app', TESTS_ROOT_DIR . '/fixtures/app/config/'); $app = new Application(); $app->registerModules($modules); require_once TESTS_ROOT_DIR . '/fixtures/app/Bootstrap.php'; $config = (require TESTS_ROOT_DIR . '/fixtures/app/config/config.php'); $config = new \Phalcon\Config($config); $bootstrap = new \Bootstrap($config); $bootstrap->setup(); $this->bootstrap = $bootstrap; }
if (!isset($load[0])) { return false; } if ($load[0] <= $max_load_avg) { // 未超过负载,则跳出 return false; } $msg_tpl = "[%s] HOST:%s LOAD:%s ARGV/URI:%s\n"; $time = @date(DATE_RFC2822); $host = php_uname('n'); $load = sprintf('%.2f', $load[0]); if (php_sapi_name() == "cli" || empty($_SERVER['PHP_SELF'])) { $argv_or_uri = implode(',', $argv); } else { $argv_or_uri = $_SERVER['REQUEST_URI']; } $msg = sprintf($msg_tpl, $time, $host, $load, $argv_or_uri); if (@is_dir($dir_log)) { @file_put_contents($dir_log . "php-server-overload.log", $msg, FILE_APPEND); } # exit with 500 page header("HTTP/1.1 500 Internal Server Error"); header("Expires: " . gmdate("D, d M Y H:i:s", time() - 99999) . " GMT"); header("Cache-Control: private"); header("Pragma: no-cache"); exit(file_get_contents($dir_wwwroot . 'errors/server_overload.html')); } _load_protection(); include $dir_library . 'bootstrap.php'; Bootstrap::setup();
<?php /** * @author Sławomir Żytko <*****@*****.**> * @copyright (c) 2014, Amsterdam Standard */ error_reporting(E_ALL); define('APP_ROOT', dirname(dirname(__FILE__))); try { require APP_ROOT . '/../../vendor/autoload.php'; require APP_ROOT . '/app/Bootstrap.php'; $config = (require APP_ROOT . '/app/config/config.php'); $bootstrap = new \Bootstrap(new \Phalcon\Config($config)); echo $bootstrap->setup()->run($_SERVER['REQUEST_URI']); } catch (\Exception $ex) { echo $ex->getMessage(); echo $ex->getTraceAsString(); }
<?php /** * @author Sławomir Żytko <*****@*****.**> * @copyright (c) 2014, Amsterdam Standard */ error_reporting(E_ALL); define('APP_ROOT', dirname(dirname(__FILE__))); require APP_ROOT . '/vendor/autoload.php'; require APP_ROOT . '/app/Bootstrap.php'; $config = (require APP_ROOT . '/app/config/config.php'); $bootstrap = new \Bootstrap(new \Phalcon\Config($config)); echo $bootstrap->setup()->run();
$argv_or_uri = implode(',', $argv); } else { $argv_or_uri = $_SERVER['REQUEST_URI']; } $msg = sprintf($msg_tpl, $time, $host, $load, $argv_or_uri); if (is_dir($dir_log) && is_writeable($dir_log . "php-server-overload.log")) { @file_put_contents($dir_log . "php-server-overload.log", $msg, FILE_APPEND); } # exit with 500 page header("HTTP/1.1 500 Internal Server Error"); header("Expires: " . gmdate("D, d M Y H:i:s", time() - 99999) . " GMT"); header("Cache-Control: private"); header("Pragma: no-cache"); exit(file_get_contents($dir_wwwroot . 'errors/server_overload.html')); } // 执行负载保护脚本 if ($max_load_avg > 0) { _load_protection(); } // 是否直接执行Core::run(); // 可在其它的文件中include此文件然后设置此变量 // 如果设置false则只初始化Bootstrap和Core类,不会执行Core::run();方法,通常用在shell文件里 if (!isset($auto_run)) { // 默认直接执行 $auto_run = true; } else { $auto_run = (bool) $auto_run; } include dirname(__FILE__) . '/core/bootstrap.php'; Bootstrap::setup($auto_run);