PHP Classes

Simple PHP Router Library: Route requests to different scripts based on URLs

Recommend this page to a friend!
  Info   View files Example   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 79%Total: 578 All time: 5,323 This week: 107Up
Version License PHP version Categories
folderbase-php-route 0.13GNU General Publi...5HTTP, PHP 5, Files and Folders, Desig...
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.

Picture of afshin akhgar
  Performance   Level  
Name: afshin akhgar <contact>
Classes: 3 packages by
Country: Iran Iran
Age: 38
All time rank: 251242 in Iran Iran
Week rank: 312 Up8 in Iran Iran Up
Innovation award
Innovation award
Nominee: 1x

Recommendations

url rewriting
I need rewrite url in my site

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!

[AUR]()

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)

  Files folder image Files  
File Role Description
Files folder imageexamples (2 files, 1 directory)
Files folder imagelib (1 file)
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file 404.php Aux. Auxiliary script
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file _config.yml Data Auxiliary data

  Files folder image Files  /  examples  
File Role Description
Files folder imagesub (1 file, 1 directory)
  Accessible without login Plain text file afshin.php Aux. Auxiliary script
  Accessible without login Plain text file test.php Aux. Auxiliary script

  Files folder image Files  /  examples  /  sub  
File Role Description
Files folder imagesubsub (1 directory)
  Accessible without login Plain text file iran.php Aux. Auxiliary script

  Files folder image Files  /  examples  /  sub  /  subsub  
File Role Description
Files folder imagemodule (2 files)

  Files folder image Files  /  examples  /  sub  /  subsub  /  module  
File Role Description
  Accessible without login Plain text file module.php Aux. Auxiliary script
  Accessible without login Plain text file param.php Aux. Auxiliary script

  Files folder image Files  /  lib  
File Role Description
  Plain text file Router.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:578
This week:0
All time:5,323
This week:107Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:79%StarStarStarStar
Rank:31