Ratings | | Unique User Downloads | | Download Rankings |
79% | | Total: 584 | | All time: 5,297 This week: 43 |
|
Description | | Author |
This class can route requests to different scripts based on URLs.
It takes an array of supported routes and checks it to see if the current request URL matches any of the routes.
The class can route the requests to the respective script defined in the routes array.
Missing routes makes the class handle the request with a not found script. | |
|
|
Innovation award
Nominee: 1x |
|
Recommendations
Example
<?php
/**
* Created by PhpStorm.
* User: akhgar-af
* Date: 8/9/2016
* Time: 10:46 AM
*/
GLOBAL $includePath;
GLOBAL $assetsUrl;
$includePath = '/';
require_once './lib/router.php';
$router = new Router();
return $router->go(array(
'afshin'=>'examples/afshin.php',
'/'=>'examples/afshin.php',
'test'=> 'examples/test.php',
'sub/iran' => 'examples/sub/iran.php',
'sub/subsub/module' => 'examples/sub/subsub/module/module.php',
'sub/subsub/param/:param1/:param2/:param3' => 'examples/sub/subsub/module/param.php',
));
|
Details
Folderbase PHP Router!
[]()
A lightweight and simple object oriented PHP Router.
Built by Afshin Akhgar- http://www.akhgar.net
Features
-
Static Route
-
Dynamic Route
-
Parameter Support => akhgar.net/param1/a/param2/b
-
Folder and file and subfolders routing
-
Subrouting
-
Parameter sending over url and query String Support
-
Custom 404 handling
-
Works fine in subfolders
> Note:
> - This Library is under development
<i class="icon-file"></i> Demo
-
First of all get the lib
-
Include it in your php index file
-
Call The router go Method
GLOBAL $includePath;
GLOBAL $assetsUrl;
$includePath = '/';
require_once './lib/router.php';
$router = new Router();
return $router->go(array(
'afshin'=>'examples/afshin.php',
'/'=>'examples/afshin.php',
'/sub/:param1/:param2/:param3:/param:4'=>'examples/params.php',
));
<i class="icon-file"></i> Parameter
'/sub/:param1/:param2/:param3:/param:4'=>'examples/params.php'
get Parameters with Array ($parameters)
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.