Skip to content

Instantly share code, notes, and snippets.

@M1ke
Created July 10, 2015 12:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save M1ke/619adb5c26f16f845c79 to your computer and use it in GitHub Desktop.
Explaining request for help in the Aura router.
<?php
// router instantiation
$uri = $_SERVER['REQUEST_URI'];
$request = strip_query($uri);
$request_arr = explode('/', urldecode($uri));
foreach ($request_arr as &$param){
$param = ucfirst($param);
}
$class = 'MyApp\\'.implode('\\', $request);
// Check for existence of a direct class (db, ajax or other non-page routers)
if (class_exists($class)){
return $class;
}
/*
So a call to
domain.com/path/to/route
Would attempt to find a class
MyApp\Path\To\Route
Wheras a call to
domain.com/this/is/a/route
Would search for a class
MyApp\This\Is\A\Route
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment