<?php $route = new Route(); $route->add('', array('controller' => 'TestApp')); $route->add('index', array('controller' => 'TestApp', 'action' => 'index')); $route->add('post', array('controller' => 'TestApp', 'action' => 'post')); $route->add('post_with_get_params', array('controller' => 'TestApp', 'action' => 'post_with_get_params')); $route->add('upload', array('controller' => 'TestApp', 'action' => 'upload')); $route->add('multiple_template', array('controller' => 'TestApp', 'action' => 'multiple_template')); $route->add('500', array('controller' => 'TestApp', 'action' => 'error_500')); $route->add('without_view', array('controller' => 'TestApp', 'action' => 'without_view'));
<?php /** * Routing system */ $route = new Route(); // User define function $route->add('/h', function () { echo 'hey this is home page'; }); // Routing controller $route->add('/login', 'login'); $route->add('/account', 'account'); $route->add('/dashboard', 'dashboard'); $route->add('/error', 'error'); $route->add('/home', 'home'); // $route->run();
<?php Route::add('any', '/', 'Controllers\\Guest\\PageController::home'); Route::add('get', '/contact/<?name?>', 'Controllers\\Guest\\PageController::contact'); Route::add('post', '/upload', 'Controllers\\Guest\\PageController::upload');
<?php require 'Route.php'; function simulate_uri($uri) { foreach (Route::all() as $route) { $route->compile(); if ($route->matches($uri)) { //var_dump($route->getData()); call_user_func_array($route->getCallback(), $route->getData()); } } } /* Tests */ Route::add('site/test', 'SiteController::contactAction'); Route::add('{controller}/{action}/{id?}', function ($controller, $action, $id) { echo $controller, ' ', $action, ' ', $id; })->where('action', 'user'); Route::add('{controller}/{action}/{id}', function ($controller, $action, $id) { echo sprintf('Te saluta %s::%s(%s) ^_^', $controller, $action, $id); })->where('id', '[0-9]+'); Route::add('{lang}/{controller}/{action?}', function ($lang, $controller, $action = null) { }); simulate_uri('user/settings/1005321');
<?php /* | Project: fw | Description: my framework | Author: Pham Ngoc Phu | Alias: Phu Master | Email: phumaster.dev@gmail.com */ /* * all route */ Route::add('/', 'WelcomeController@hello'); Route::add('/phumaster', function () { var_dump(get('test')); var_dump($_SESSION); }); Route::add('/{name}', function ($name) { return view('welcome', compact('name')); });
<?php /** * Routing system */ $route = new Route(); $route->add('/', function () { echo json_encode("BKSOICT SERVER SERVICE!"); }); // Routing controller $route->add('/login', 'login'); $route->add('/logout', 'logout'); $route->add('/group', 'group'); $route->add('/notification', 'notification'); $route->add('/schedule', 'schedule'); $route->add('/student', 'student'); $route->add('/user_class', 'user_class'); $route->add('/user', 'user'); $route->add('/class_room', 'class_room'); $route->add('/session', 'session'); // $route->run();
<?php /* Route example */ $route = new Route('example', 'Index'); // Creating a route with a controller, the model will be extracted by the getModel method $route->add(array('', 'index.html'), function () { // When the url is index.html -> call Closure echo 'Hello world'; }); $route->add(array('article-{id}.html', 'id' => '[0-9]+'), Query('getArticle', Get('id')), Action('showArticle')); // Calling model method getArticle and giving result to controller method showArticle $route->add(array('articles.html/{page?}', 'page' => '[0-9]+'), Query('getArticles', array(Get('page'), QUERY_ELSE => 0)), Action('showArticles')); // Then feeding the result to showArticles method $route->add('article-create', Permission(), Event('getFormEvent', array(Query('newArticle', Get('name')), Action('showArticle'), EVENT_ELSE => Action('writeArticle')))); // // If the form isn't completed, show the writeArticle form return $route;
<?php $route = new Route(); $route->add('', array('controller' => 'my')); // Default root-route $route->add('403', array('controller' => 'my', 'action' => 'action_403')); $route->add('unknow', array('controller' => 'unknow', 'action' => 'plop')); $route->add('unknow_action', array('controller' => 'my', 'action' => 'plop'));
<?php // create routes object $route = new Route(); // add top level routes & corisponding controllers $route->add('/', 'homeController'); $route->add('/login', 'loginController'); $route->add('/logout', 'logoutController');
<?php /* * Aca se agregan las rutas */ Route::add('/', 'Main@StartView'); Route::add('/other_method', 'Main@StartView@otherMethod'); Route::add('/anonymous', function () { echo 'This is an anonymous function.'; });
<?php // Routes Config // // Routes are based on simple regular expressions // // - Two types, manual routing and auto routing // // - These are in order of adding so put catch-alls last // and specific routes first. namespace lib; $routes = new Route(isset($_GET['url']) ? $_GET['url'] : 'index'); $routes->add(array('name' => 'home page', 'type' => 'manual', 'route' => '/^index$/', 'controller' => 'pages', 'action' => 'index', 'params' => isset($_GET['url']) ? $_GET['url'] : 'index')); $routes->add(array('name' => 'controlled pages', 'type' => 'auto', 'route' => '/^(?<controller>[0-9A-Za-z-_]+)?\\/?(?<action>[0-9A-Za-z-_]+)?\\/?(?<params>[0-9A-Za-z-_]+)?\\.?(?<ext>.*)?\\/?/')); // add the 404 route last $routes->add(array('name' => '404', 'type' => 'manual', 'route' => '/.*/', 'controller' => 'error', 'action' => 'fourohfour'));
<?php if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } //we need to go through and initialize all of the modules we need to use Jx_Modules::init(); Route::add('media', 'media/<action>/<file>(.<ext>)', null, 'admin')->defaults(array('controller' => 'media')); //add event callbacks as needed Jx_Event::addObserver(array('Jx_Modules', 'onGetAdminMenu'), 'getAdminMenu'); Jx_Event::addObserver(array('Jx_Settings', 'onGetAdminMenu'), 'getAdminMenu');
<?php include '../lib.php'; function __autoload($class) { $file_path = 'lib/' . $class . '.php'; if (file_exists($file_path) == false) { $file_path = 'controllers/' . $class . '.php'; } require_once $file_path; } $route = new Route(); $route->add(['/about', '/contact']); $route->submit();
/** * @param string $method * @param string $url * @param array $destination * @retun \Route\Path */ public static function &addRoute($method, $url, $destination, $name) { $bt = debug_backtrace(); $file = $bt[0]['file']; if (isset($bt[0]['class'])) { $class = $bt[0]['class']; } if (strpos($destination, '.') !== false) { $expl = explode('.', $destination); $destClass = $expl[0]; $destMethod = $expl[1]; $oReflectionClass = new ReflectionClass($class); $namespace = $oReflectionClass->getNamespaceName(); if (substr($destClass, 0, 1) == "\\") { if (isset($class)) { self::$routes[$name] = ['call' => [$destClass, $destMethod], 'caller' => ['class' => $class, 'file' => $file]]; } else { self::$routes[$name] = ['call' => [$destClass, $destMethod], 'caller' => ['file' => $file]]; } } else { $cl = "\\" . $namespace . "\\" . $destClass; if (isset($class)) { self::$routes[$name] = ['call' => [$cl, $destMethod], 'caller' => ['class' => $class, 'file' => $file]]; } else { self::$routes[$name] = ['call' => [$cl, $destMethod], 'caller' => ['file' => $file]]; } } } else { if (isset($class)) { self::$routes[$name] = ['call' => [$class, $destination], 'caller' => ['class' => $class, 'file' => $file]]; } else { self::$routes[$name] = ['call' => $destination, 'caller' => ['file' => $file]]; } } return \Route::add($method, $url, 'ModuleController.' . $name); }
<?php Route::add('users', 'user(/<action>)', null, 'admin')->defaults(array('controller' => 'user', 'action' => 'login')); Route::add('user_admin', 'admin/user/<action>(.<format>)', array('format' => 'html|xml|json|rss'), 'admin')->defaults(array('directory' => 'admin', 'controller' => 'user', 'format' => 'json'));
<?php include 'route.php'; $route = new Route(); $route->add('/'); $route->add('/news'); $route->add('/contact'); echo '<pre>'; print_r($route); $route->submit();
echo 'DEBUG:' . $line . '<br>'; } $count_id++; } spl_autoload_register(function ($name) { $class = strtolower($name); $class = preg_replace('/\\\\/', '/', $class); $class = $class . '.class.php'; if (file_exists(SP_SYSTEM . '/' . $class)) { include_once SP_SYSTEM . '/' . $class; } elseif (file_exists(SP_SYSTEM . '/core/' . $class)) { include_once SP_SYSTEM . '/core/' . $class; } }); ///debug('Я твою мамку ебал1111', true); //Config::set('cache_expire_default', 1000); //Config::save(); //Cache::set('Babka', '450', '2000000'); //Cache::clear(); //echo Cache::get('Babka'); //Route::add('/user{id}/{category}',' '); Route::add('/user;№/вася_пупкин', 'khujnia'); Route::add('/fsggsdgs/gsdgsg/sg/ss/fad/fs/dfs/', ' '); Route::add('sg/d/g*№!"№;:?*()s/*g/*s/g*/s*', 'fffffffff'); Route::add('@/$/^&/*(gf/g', ' '); $param = Route::search('///sg/d/g*№!"№;:?*()s/*g/*s/g*/s*////'); //if($param!= null) {echo $param.' чтото да вернули';} //else echo $param.' всё поломалось'; //if( Route::search('/pageporn/')!=null ) {echo 'Возвращает :)';} //else echo 'Не возвращает :('; echo $_SERVER['REQUEST_URI'];
<? include 'route.php'; require_once "Spyc.php"; $route = new Route(); $locale = 'ko'; $permalink = ''; $home_url = "/typojanchi2015"; $browser_locale_detect_needed = true; $route->add('/', function() { global $browser_locale_detect_needed; $browser_locale_detect_needed = true; }); $route->add('/ko', function() { global $browser_locale_detect_needed; $browser_locale_detect_needed = false; }); $route->add('/en', function() { global $locale, $browser_locale_detect_needed; $browser_locale_detect_needed = false; $locale = "en"; }); $route->add('/ko/.+', function($name) {
<?php /** * Created by PhpStorm. * User: florianauderset * Date: 09.12.15 * Time: 13:48 */ $route = new Route(); $route->add("/", "HomeView"); $route->add("/produkte", "ProductView"); $route->add("/produits", "ProductView"); $route->add("/products", "ProductView"); $route->add("/produkt", "SingleProductView"); $route->add("/produit", "SingleProductView"); $route->add("/product", "SingleProductView"); $route->add("/cart", "CartView"); $route->add("/warenkorb", "CartView"); $route->add("/panier", "CartView"); $route->add("/checkout", "CheckoutView"); $route->add("/kasse", "CheckoutView"); $route->add("/caisse", "CheckoutView"); $route->add("/register", "RegisterView"); $route->add("/registrieren", "RegisterView"); $route->add("/registrer", "RegisterView"); $route->add("/kontakt", "ContactView"); $route->add("/contact", "ContactView"); $route->add("/login", "LoginView"); $route->add("/logout", "LoginView"); $route->add("/myaccount", "CustomerView"); // dynamically create page-routes from db
<?php # Auth Basic Routes Route::add('/', 'offline\\Users login'); Route::add('/offline', 'offline\\Users login'); Route::add('/sign_up', 'offline\\Users sign_up'); Route::add('/logout', 'admin\\Users logout'); # Auth Email Routes Route::add('/password_forgot_email', 'offline\\Users password_forgot_email'); Route::add('/confirm_account_email', 'offline\\Users confirm_account_email'); Route::add('/password_expired_email', 'offline\\Users password_expired_email'); Route::add('/unlock_account_email', 'offline\\Users unlock_account_email'); # Auth Hash Routes Route::add('/confirm_account', 'offline\\Users confirm_account'); Route::add('/password_forgot', 'offline\\Users password_forgot'); Route::add('/unlock_account', 'offline\\Users unlock_account'); Route::add('/password_expired', 'offline\\Users password_expired'); # admin Route::add('/admin', 'admin\\Users index'); Route::add('/paginate', 'admin\\Users paginate');
<?php namespace App; Route::add("/", "GET", "routeName", "HomeController", "homePage"); Route::add("/page/:title/:text", "GET", "routeName", "HomeController", "aboutPage");
<?php Route::addGet('/', ['controller' => 'Dashboard', 'action' => 'index'])->setName('daison_mainRouteManager'); Route::addPost('/', ['controller' => 'Auth', 'action' => 'login'])->setName('daison_postLogin'); Route::addGet('/logout', ['controller' => 'Auth', 'action' => 'logout'])->setName('daison_postLogout'); Route::addGet('/users', ['controller' => 'User', 'action' => 'lists'])->setName('daison_showUsers'); Route::addGet('/users/{id}/view', ['controller' => 'User', 'action' => 'view'])->setName('daison_viewUser'); Route::addGet('/users/{id}/edit', ['controller' => 'User', 'action' => 'edit'])->setName('daison_editUser'); Route::add('/users/{id}/delete', ['controller' => 'User', 'action' => 'delete'])->setName('daison_deleteUser'); Route::add('/users/{id}/resend-confirmation', ['controller' => 'User', 'action' => 'resendConfirmation'])->setName('daison_resendConfirmationUser'); //Route::add( // '/{resource}', // [ // 'controller' => 'Dynamic', // 'action' => 'index', // ] //); // //Route::add( // '/{resource}/{id}/view', // [ // 'controller' => 'Dynamic', // 'action' => 'view', // ] //); // //Route::add( // '/{resource}/{id}/edit', // [ // 'controller' => 'Dynamic', // 'action' => 'edit',
<?php include "SiteController.php"; include "ProfileController.php"; include "CategoryController.php"; include "RecipeController.php"; include "CommentController.php"; include "UserController.php"; include "header.php"; include "sidebar.php"; include "route.php"; $route = new Route(); $route->add('/profile', 'ProfileController', 'index'); $route->add('/category', 'CategoryController', 'index'); $route->add('/category-add', 'CategoryController', 'CreateAction'); $route->add('/category-update', 'CategoryController', 'UpdateAction'); $route->add('/category-del', 'CategoryController', 'DeleteAction'); $route->add('/recipes', 'RecipeController', 'index'); $route->add('/recipe-add', 'RecipeController', 'CreateAction'); $route->add('/recipe-update', 'RecipeController', 'UpdateAction'); $route->add('/recipe-del', 'RecipeController', 'DeleteAction'); $route->add('/comments', 'CommentController', 'index'); $route->add('/comment-add', 'CommentController', 'CreateAction'); $route->add('/comment-update', 'CommentController', 'UpdateAction'); $route->add('/comment-del', 'CommentController', 'DeleteAction'); $route->add('/users', 'UserController', 'index'); $route->add('/user-add', 'UserController', 'CreateAction'); $route->add('/user-update', 'UserController', 'UpdateAction'); $route->add('/user-del', 'UserController', 'DeleteAction'); $route->run(); include "footer.php";
public function __construct() { $this->routes = new SplObjectStorage(); return Route::add($this); }
<?php $modules = array('database', 'auth'); // Routing Route::add('news', '<controller>/<action>/<id>', array('controller' => 'news', 'action' => 'view')); Route::add('rozmowa', 'telefon(/<action>)', array('controller' => 'contact', 'action' => 'index')); Route::add('costam', '<controller>', array('action' => 'index')); Route::add('default', '(<controller>(/<action>))', array('controller' => 'start', 'action' => 'index'));
//Do something echo 'Hello from test.html'; }); //complex route with parameter Route::add('user/(.*)/edit', function ($id) { //Do something echo 'Edit user with id ' . $id . '<br/>'; }); //accept only numbers as the second parameter. Other chars will result in a 404 Route::add('foo/([0-9]*)/bar', function ($var1) { //Do something echo $var1 . ' is a great number!'; }); //long route Route::add('foo/bar/foo/bar', function () { //Do something echo 'hehe :-)<br/>'; }); //crazy route with parameters (Will be triggered on the route pattern above too because it matches too) Route::add('(.*)/(.*)/(.*)/(.*)', function ($var1, $var2, $var3, $var4) { //Do something echo 'You have entered: ' . $var1 . ' / ' . $var2 . ' / ' . $var3 . ' / ' . $var4 . '<br/>'; }); //Add a 404 Not found Route Route::add404(function ($url) { //Send 404 Header header("HTTP/1.0 404 Not Found"); echo '404 :-(<br/>'; echo $url . ' not found!'; }); Route::run();
<?php /** * Define the route(s) we need in this file */ Route::add('loader', 'loader', null, 'admin')->defaults(array('controller' => 'loader', 'action' => 'index'));
<?php include 'route.php'; include 'src/home.php'; include 'src/about.php'; include 'src/contact.php'; $route = new Route(); $route->add('/', function () { echo "This is the homepage."; }); $route->add('/about', function () { echo "This is the about page."; }); $route->add('/contact', function () { echo "This is the the contact page."; }); $route->submit(); // Enter in browser: localhost/routing-project/ output: This is the homepage. // Enter in browser: localhost/routing-project/ output: This is the about page. // Enter in browser: localhost/routing-project/ output: This is the contact page.