PHP Classes

PHP Router Class Package: Handle HTTP requests routing to controller classes

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 70 All time: 10,286 This week: 87Up
Version License PHP version Categories
php-router-class 1.0.0BSD License5HTTP, PHP 5, Design Patterns
Description 

Author

This package can handle HTTP requests routing to controller classes.

It provides a router class that can register the HTTP request URL patterns it can handle and the controller paths associated with each HTTP URL pattern.

There is a request class that can retrieve the HTTP request variables.

The router class can process the current request and route it to a controller class that matches the current request URL pattern.

Picture of Vitalij Mik
  Performance   Level  
Name: Vitalij Mik <contact>
Classes: 7 packages by
Country: Germany Germany
Age: 37
All time rank: 3482194 in Germany Germany
Week rank: 164 Up8 in Germany Germany Up
Innovation award
Innovation award
Nominee: 5x

Example

<?php
error_reporting
(E_ALL);

require_once
__DIR__ . '/Router.php';
require_once
__DIR__ . '/Request.php';

$router = require_once __DIR__ . '/routes.php';

$request = Request::createFromGlobal();

try{
    echo
$router->handle($request);
}catch (
RouteNotFoundException $exception){
    echo
$exception->getMessage();
}


  Files folder image Files (8)  
File Role Description
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Plain text file IndexController.php Class Class source
Plain text file ProfileController.php Class Class source
Plain text file Request.php Class Class source
Plain text file RouteNotFoundException.php Class Class source
Plain text file Router.php Class Class source
Accessible without login Plain text file routes.php Conf. Configure the application URL patterns and controller classes

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:70
This week:0
All time:10,286
This week:87Up