function start () { // Output-buffering: ON ob_start(); // Pre-view middleware // ### TODO ### // Use the Router to map the command string to a view try { $router = new Router($this->routes, $this->command); $router->start(); } catch (Http404Exception $e) { return self::http_404($e->getMessage()); } catch (Exception $e) { return self::http_500($e->getMessage()); } // Post-view middleware // ### TODO ### // Output-buffering: Flush ob_end_flush(); }
/** * Application run */ public function run() { // Router start $router = new Router(); $route = $router->start(); echo '<pre>'; print_r($route); echo '</pre>'; // Dispatcher if (!empty($route)) { $controller_class = 'Controller' . ucfirst($route[controller]); // Check exists this controller if (class_exists($controller_class)) { $controller = new $controller_class(); $action = 'action' . ucfirst($route[action]); // Check action exists if (method_exists($controller, $action)) { $controller->{$action}(); } } } }
<?php session_start(); ini_set('display_errors', 1); error_reporting(E_ALL); header("Content-Type: text/html; charset=utf-8"); require_once 'core/autoload.php'; require_once 'core/registry.php'; //require_once 'site_config.php'; require_once 'core/model.php'; require_once 'core/view.php'; require_once 'core/controller.php'; require_once 'core/router.php'; //echo '->'.$_SESSION['usr']['id']; //---------------------------- Tools::getSiteConfig(); //---------------------------- Tools::getSiteData(); //---------------------------- Tools::getUserData(); //---------------------------- Tools::getAccessData(); Router::start();
<?php require_once 'core/model.php'; require_once 'core/controller.php'; require_once '/helpers/functions.php'; $route = new Router(); $route->start();
<?php // Показываем все ошибки ini_set('display_errors', 1); // Корневая директория define('ROOT', $_SERVER['DOCUMENT_ROOT']); // Логировать запросы и прочее? define('LOG', TRUE); // Ядро require_once 'core/mi.php'; // Запускаем Micros Mi::init(); // Загружаем роутер $router = new Router(); // Запускаем роутер $router->start();
public function init($config) { self::$config = json_decode(json_encode($config), false); $router = new Router(); $router->start(); }
function route ($root, $route) { // Get the root path from where admin is running self::$root = url(Frix::config('WEB_ROOT'), $root, '/'); self::$route = $route; // Put the root path into the URL self::$context['root'] = self::$root; // TODO: create some type of decorator to require authentication on views // to avoid this kind of hack manually checking the route here... // Forgot password route? if (str_replace('/', '', $route) == 'forgot') { return $this->forgot(); } // Load Auth app $auth_app = Frix::app('auth'); // Check if user is authorized if (!$auth_app->get_user()) { return $this->login(); } // Load Admin app $this->admin = Frix::app('admin'); // List all the installed apps foreach (Frix::config('APPS') as $name => $path) { // Create an App instance $app = Frix::app($name); // Try to import options try { import(join_path(array($app->path, 'admin.php'))); } // Go to next app on failure catch (ImportException $e) { continue; } // Any registered model? if (array_key_exists($name, $this->admin->registry)) { // Inject an URL attribute in the app $app->admin_url = url(self::$root, $name); self::$context['apps'][$name] = $app; } } // Initialize breadcrumbs self::$context['breadcrumbs'] = array(); // Load route config // TODO: make router allow URL 'inclusions' instead of creating multiple routers require_once(join_path(array($this->admin->path, 'routes.php'))); // Use the Router to map the command string to a view // TODO: try to trick Router to jump the application resolval // and use this instance of the views $router = new Router($routes, $route); $router->start(); // Let the template know what view is running self::$context['view_name'] = $router->view_name; }