PHP Classes
elePHPant
Icontem

Simple PHP Routers: Route HTTP requests to given callback functions

Recommend this page to a friend!
  Info   View files Example   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-04-04 (8 months ago) RSS 2.0 feedNot enough user ratingsTotal: 41 This week: 2All time: 9,066 This week: 337Up
Version License PHP version Categories
routers 1.0.0GNU General Publi...5HTTP, PHP 5, Design Patterns
Description Author

This package can route HTTP requests to given callback functions.

It can register several URL regular expression patterns and callback functions that will be called when the current request matches the respective pattern.

It can also take regular expressions to extract parameter values from the request URL.

  Performance   Level  
Name: carlos carvalho <contact>
Classes: 4 packages by
Country: Brazil Brazil
Age: 35
All time rank: 3404270 in Brazil Brazil
Week rank: 209 Up7 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

Details

routers

Latest Stable Version Total Downloads Latest Unstable Version License

Simple Routers PHP

>Examples

<?php use App\Router\Router;

$router = new App\Router\Router($_SERVER["REQUEST_URI"]); $router->get('/',function(){

echo 'home page';

});

$router->get('/posts/:id-:slug',function($id, $slug) use ($router){

echo $router->url('Blog#show',['id'=>1,'slug'=>'slugsd-idads']);

},'posts.show')->with('id','[0-9]+')->with('slug','([a-z\-0-9]+)');

$router->get('/posts/:id','Blog#show');

$router->post('/posts/:id',function($id){

print_r($_POST); });

$router->run();

Use Custom Controllers

$router->get('/posts','Blog#show');

Create new Controller BlogController.php

  Files folder image Files  
File Role Description
Files folder imagesrc (2 directories)
Files folder imagevendor (1 file, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file rewriterConfig.php Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
Files folder imageControllers (1 file)
Files folder imageRouter (3 files)

  Files folder image Files  /  src  /  Controllers  
File Role Description
  Plain text file BlogController.php Class Class source

  Files folder image Files  /  src  /  Router  
File Role Description
  Plain text file Route.php Class Class source
  Plain text file Router.php Class Class source
  Plain text file RouterException.php Class Class source

  Files folder image Files  /  vendor  
File Role Description
Files folder imagecomposer (5 files)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script

  Files folder image Files  /  vendor  /  composer  
File Role Description
  Accessible without login Plain text file autoload_classmap.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_namespaces.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_psr4.php Aux. Auxiliary script
  Plain text file autoload_real.php Class Class source
  Plain text file ClassLoader.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:41
This week:2
All time:9,066
This week:337Up