public static function init() { if (self::$init == null) { self::$init = new self(); } return self::$init; }
* * @subpackage UnitTest */ class Bootstrap { protected static $serviceManager; public static function init() { static::initAutoloader(); } protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); $loader = (include $vendorPath . '/autoload.php'); } protected static function findParentPath($path) { $dir = __DIR__; $previousDir = '.'; while (!is_dir($dir . '/' . $path)) { $dir = dirname($dir); if ($previousDir === $dir) { return false; } $previousDir = $dir; } return $dir . '/' . $path; } } Bootstrap::init();
<?php error_reporting(E_ALL); ini_set('display_errors', 1); header('Content-Type: text/html; charset=utf-8'); mb_internal_encoding('UTF-8'); require_once __DIR__ . '/../modules/Bootstrap.php'; //Add Composer autoloader. This loads Phalcon incubator require_once __DIR__ . '/../vendor/autoload.php'; $app = new Bootstrap('frontend'); $app->init();
<?php //Config require 'config.php'; // spl_autoload_register = alternative function __autoload($class) { if (file_exists(LIBS . $class . '.class.php')) { require LIBS . $class . '.class.php'; } else { if (file_exists(UTILS . $class . '.class.php')) { require UTILS . $class . '.class.php'; } } } // Load the Bootstrap $bootstrap = new Bootstrap(); //Optional Path settings //$bootstrap->setControllerPath(); //$bootstrap->setModelPath(); //$bootstrap->setDefaultFile(); //$bootstrap->setErrorPath(); // Start the Bootstrap $bootstrap->init();
/** * 运行调度器 * */ public function run() { // APP运行的开始时间 $this->_setDebugInfo('beginTime', microtime(true)); // 运行应用的 Bootstrap require APPLICATION_PATH . '/Bootstrap.php'; $bootStrap = new Bootstrap(); $bootStrap->init(); // 解析当前的URI(包括解析路由) $this->_parseUri(); // 得到控制器 $controller = $this->_getController(); $action = $this->_action . 'Action'; // 判断动作是否存在 if (!method_exists($controller, $action)) { throw new QP_Exception('控制器:' . get_class($controller) . ' 中未定义动作:' . $action, QP_Exception::EXCEPTION_NO_ACTION); } // 选择的动作 $this->_setDebugInfo('action', $action); // 把执行的输出先保存起来放到 Layout 中显示 ob_start(); // 执行 init 方法 $controller->init(); // 执行动作 $controller->{$action}(); // 得到所有输出内容 $viewContent = ob_get_clean(); // 是否自动输出视图 if ($controller->viewIsAutoRender()) { $controller->view->setPath($this->_controllerPath); $viewContent .= $controller->view->render($this->_action . '.html'); // 使用的视图 $this->_setDebugInfo('view', $this->_action . '.html'); } // 是否启用了 Layout if (QP_Layout::isEnabled()) { // 将 Layout 当作当前视图的一部分 $view = QP_View::getInstance(); $view->setPath(APPLICATION_PATH . '/Views/Layouts', true); // 将布局的变量与重新赋值给视图 $view->assign(QP_Layout::get()); // 'LayoutContent' 为框架的布局内容引用 $view->LayoutContent = $viewContent; $layoutName = QP_Layout::name(); $viewContent = $view->render($layoutName); // 使用的 Layout $this->_setDebugInfo('layout', $layoutName); } // 如果是 SAPI 运行模式就要设置字符集,防止乱码 if (PHP_SAPI != 'cli') { header("Content-Type:text/html; charset=" . $this->_appConfig['charset']); } // 有视图内容则输出 if ($viewContent != '') { echo $viewContent; } // APP运行的结束时间 $this->_setDebugInfo('endTime', microtime(true)); // 如果显示调试信息 并且 当前不是 AJAX 的请求 并且框架不是以 CLI方式运行 if ($this->_appConfig['debug'] && !$this->_request->isAjax() && PHP_SAPI != 'cli') { $debugInfo = $this->_debugInfo; include QUICKPHP_PATH . '/Debug/Debuginfo.php'; } }
require_once path('config') . DS . 'application.php'; if (!$cli) { if (fnmatch('*/mytests', $_SERVER['REQUEST_URI'])) { self::tests(); } else { self::router(); } } } private static function tests() { } public static function assetAged($asset) { $file = __DIR__ . $asset; if (file_exists($file)) { return sha1(filemtime($file) . $file); } return 1; } public static function router() { libProject('cmsrouter'); } public static function finish() { $time = Timer::get(); } } Bootstrap::init(isset($cli));
/** * Factory style constructor works nicer for chaining. This * should also really only be used internally. The Request::get, * Request::post syntax is preferred as it is more readable. * @return Request * @param string $method Http Method * @param string $mime Mime Type to Use */ public static function init($method = null, $mime = null) { // Setup our handlers, can call it here as it's idempotent Bootstrap::init(); // Setup the default template if need be if (!isset(self::$_template)) { self::_initializeDefaults(); } $request = new Request(); return $request->_setDefaults()->method($method)->sendsType($mime)->expectsType($mime); }
<?php require __DIR__ . '/../../../Rcm/test/RcmTest/Base/RcmBootstrap.php'; use RcmTest\Base\RcmBootstrap; class Bootstrap extends RcmBootstrap { } /** Array is zend special application config */ Bootstrap::init(include 'application.test.config.php');
<?php session_start(); include 'autoload.php'; Bootstrap::init($db, $err, $typehead); ?> <!DOCTYPE html> <html lang="fr"> <head> <title>Flashsms r0mdau</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="lib/bootstrap/css/bootstrap-responsive.min.css"> </head> <body> <div class="container"> <div class="span3"> <form method="post" class="form-horizontal"> <fieldset> <legend>Envoyer</legend> <label>Numero</label> <input type="text" name="number" placeholder="+33 6 xx xx xx xx" autocomplete="off" value="<?php echo isset($_SESSION['user']) ? $_SESSION['user'] : ''; ?> " data-provide="typeahead" data-items="4" data-source='<?php echo $typehead['send'];
<?php /** * Created by PhpStorm. * User: CrazyBobik * Date: 04.10.2015 * Time: 2:17 */ defined('ROOT') || define('ROOT', realpath(dirname(__FILE__) . '/..')); require_once ROOT . '/engine/bootstrap.php'; require_once ROOT . '/config/config.php'; Bootstrap::init()->autoLoader(); $path = Libs_URL::get()->getParseURL(); $file = ROOT . '/system/ajax/' . $path[1] . '.php'; if (file_exists($file)) { require_once $file; $controller = new $path[1](); $controller->{$path}[2](); } else { header('Location: /404'); }
public static function run($entrance) { spl_autoload_register(array('Application', 'autoload')); //psr-0 /** * 获取配置信息 * 同步配置包括 / 入口配置 / 模块配置 / app配置 / 默认配置 相互覆盖 * 验证 D(C()); / D(ConfigManager::getInstance($entrance)); */ ConfigManager::getInstance($entrance)->load(); //OK 配置完成 验证 /** * 计算路由信息 * 验证D(C('Router')) */ Router::getInstance()->load(); //路由信息 D(C('Router')); // if($router['method_modules']){ // $basepath = $app['APP_PATH'].'Modules/'.$app['modulelist'][$router['method_modules']].'/'; // }else{ // $basepath = $hspath; // } Bootstrap::init(); //初始化执行 /** * 对系统信息运算完毕,准备转交控制权 * 转交控制权 */ //app-> [APP_PATH] => ../App/ // [GRACE_PATH] => ../Grace/ //加载Seter spl_autoload_register(array('Application', 'autoload_controller')); //psr-0 includeIfExist(C('app')['APP_PATH'] . '/Seter/I.php'); self::DoController(); exit; exit; /** * D(C()); // // D($request->headers); // D($request->env); // D($request->cookies); // // exit; // D(C('env')); //// D($request->getMethod()); //提交的方法 //// D($request->isGet()); //提交的方法 //// D($request->isPost()); //提交的方法 //// D($request->isPut()); //提交的方法 //// D($request->isPatch()); //提交的方法 //// D($request->isDelete()); //提交的方法 //// D($request->isOptions()); //提交的方法 // // D($request->getHost()); // D($request->getHostWithPort()); // D($request->getPort()); // echo '------'; // /** // * 下面三个path模式下不准确 // * / // D($request->getScriptName()); // D($request->getRootUri()); // D($request->getPath()); // D($request->getPathInfo()); //同下 // D($request->getResourceUri()); //同上 // // D($request->getIp()); // // D($request->getRootUri()); */ /** * 调试 //验证系列配置数据 D(ConfigManager::get('modulelist')); D(ConfigManager::get('app_defaultConfig')); D(ConfigManager::get('ent')); D(ConfigManager::get('env')); D(ConfigManager::get('app')); D(C()); */ /** * 对request的验证 */ /** * 生成对象 * router * config * request * bootstrap::ini(); ->>>>>>>>>>>> 在 go 中 //================================= request ok router ok config ok bootrun ok //================================= go中 ini ok 控制权交给go Application::go -> 生成response对象 ->view/json */ /** //config //ConfigManager::Load($conf); //D(ConfigManager::get('mysql')); //D(ConfigManager::get('Rbacdb')); //D(ConfigManager::get('User')); //D(ConfigManager::get('modules')); // D(ConfigManager::get('Router')); // Router::getInstance()->load(); //$router = Router::getInstance()->getrouter(); //获得router //OK //这里准备好 // $router // $config // $_REQUEST */ //首先运行自动加载文件 exit; }
/** * @test */ public function CanInitWithoutContext() { $component = new Bootstrap(); $component->init(); }
<?php use Phalcon\Mvc\Micro; require_once './bootstrap/app.php'; require_once './module/common/util/Response.php'; require_once './module/module.php'; try { $app = new Micro(); $bootstrap = new Bootstrap(); $init = function () use($app, $bootstrap) { return $bootstrap->init($app); }; // Retrieves all robots $app->get('/', $init); // Adds a new robot $app->post('/', $init); // Updates robots based on primary key $app->put('/', $init); // Deletes robots based on primary key $app->delete('/', $init); $app->options('/{catch:(.*)}', $bootstrap->optionsRequest($app)); $app->notFound(function () use($app) { return \Common\Util\Response::error(404, 'Não encontrado!'); }); $app->handle(); } catch (Phalcon\Mvc\Micro\Exception $e) { \Common\Util\Response::error(500, $e->getMessage()); }
<?php //$start = microtime(true); /** * Created by PhpStorm. * User: CrazyBobik * Date: 23.08.2015 * Time: 20:38 */ defined('ROOT') || define('ROOT', realpath(dirname(__FILE__) . '/..')); require_once ROOT . '/engine/bootstrap.php'; require_once ROOT . '/config/config.php'; Bootstrap::init()->start(); //echo "\r\n".round(microtime(true) - $start, 3); /* * INSERT INTO site_tree SET left_key = $right_key, right_key = $right_key + 1, level = $level + 1, title='404', name='404', type='page', pid=2 * UPDATE site_tree SET right_key = right_key + 2, left_key = IF(left_key > $right_key, left_key + 2, left_key) WHERE right_key >= $right_key * INSERT INTO site_tree SET left_key = 10, right_key = 10 + 1, level = 3 + 1, title='404', name='404', type='block', pid=6 UPDATE site_tree SET right_key = right_key + 2, left_key = IF(left_key > 10, left_key + 2, left_key) WHERE right_key >= 10 * */ //TODO: админку //TODO: дизайн сайта //TODO: работа с картинками-->1 //TODO:-->2 работа с видео //TODO: (должна быть отдельно) //TODO:-->1 языки -->2 //TODO: регистрацию