public static function getInstance() { if (Route::$instance == null) { Route::$instance = new Route(); } return Route::$instance; }
/** * @return mixed */ public static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
/** * start the app */ public function run() { $this->_initRegister(); date_default_timezone_set($this->config['timezone']); if (false === IS_CLI) { $this->route = Route::instance()->init(); $this->controller = Controller::create($this->route); } }
public static function start() { $ds = DIRECTORY_SEPARATOR; include 'vendor' . $ds . 'simple' . $ds . 'base' . $ds . 'Loader' . EXT; include 'vendor' . $ds . 'simple' . $ds . 'base' . $ds . 'Handler' . EXT; include 'vendor' . $ds . 'simple' . $ds . 'base' . $ds . 'Route' . EXT; spl_autoload_register(['Loader', 'autoload']); //set the error and exception handlers Handler::set(); //set the routes Route::instance()->run(); }
public function __construct($layout = '', $view = '') { $this->_conf = Config::instance(); if (!empty($layout)) { $this->_layout = $layout; } else { $this->_layout = $this->_conf->get('default_layout'); } if (!empty($view)) { $this->_view = $view; } else { $router = Route::instance(); $this->_view = className2fileName($router->controller()) . DS . $router->action(); } }
<?php $route = Route::instance(); $route->connect('page/(\\d*)/(\\d*)', 'pages_FirstPage/index/$1/$2'); $route->connect('page', 'page/index'); $route->connect('page/test', 'test/main'); unset($route);
* Подключения файла с функциями */ include_once CORE_PATH . DS . 'functions.php'; //errorReporting (); /* * Добовляются пути к include_path */ $includePath = array(APP_PATH . DS . 'classes', CORE_PATH . DS . 'classes', get_include_path()); $includePath = implode(PATH_SEPARATOR, $includePath); set_include_path($includePath); /** * * автолод для подключения классов */ function __autoload($class) { $file = className2fileName($class) . '.php'; include_once $file; } include_once APP_PATH . DS . 'config' . DS . 'app_config.php'; // фаил конфигурации приложения $config = Config::instance(); include_once APP_PATH . DS . 'config' . DS . 'routes.php'; $router = Route::instance(); //подключаем роут $route = $router->getRoute($_SERVER['REQUEST_URI']); //текущий роут errorReporting(); //вывод ошибок dispatch($route); //фронт контроллер
public static function instance() { if (!self::$instance instanceof self) { return self::$instance = new self(); } }