<?php use Inphinit\App; use Inphinit\View; use Inphinit\Request; use Inphinit\Routing\Route; App::on('changestatus', function ($status, $msg) { if ($status === 503) { echo 'This site is currently down for maintenance and should be back soon!'; } elseif (in_array($status, array(401, 403, 404, 500, 501))) { View::forceRender(); View::render('httpview', array('title' => $msg ? $msg : 'Página inacessível', 'method' => $_SERVER['REQUEST_METHOD'], 'path' => Request::path(), 'route' => Request::path(true), 'status' => $status)); exit; } }); Route::set('ANY', '/', 'Home:index'); // Navitate to http://[server]/user/[YOUR NAME] like: http://[server]/user/mary Route::set('ANY', 're:#^/user/([a-z0-9_]+)$#', 'Users.Profile:view'); // Navitate to http://[server]/info Route::set('ANY', '/info', 'Examples:info'); // Navitate to http://[server]/closure Route::set('ANY', '/closure', 'Examples:arrayClosure');
public function prepare() { if ($this->ready) { return null; } $this->ready = true; if (empty($this->classMethods)) { Exception::raise($this->fullController . ' is empty ', 2); } $controller = $this->controller; $classMethods = $this->classMethods; foreach ($classMethods as $value) { $route = $this->getRoute($value); if ($route) { Route::set($route[0], $route[1], $controller . ':' . $value); } } }
public function prepare() { if ($this->ready) { return null; } $this->ready = true; if (empty($this->classMethods)) { Exception::raise($this->fullController . ' is empty ', 2); } $format = $this->format; $controller = $this->controller; $classMethods = $this->classMethods; foreach ($classMethods as $value) { if ($value[1] !== '' && ($format === self::BOTH || $format === self::SLASH)) { Route::set($value[0], '/' . $value[1] . '/', $controller . ':' . $value[2]); } if ($format === self::BOTH || $format === self::NOSLASH) { Route::set($value[0], '/' . $value[1], $controller . ':' . $value[2]); } } $controller = $classMethods = null; }