PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of carlos carvalho  >  Simple PHP Routers  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Simple PHP Routers
Route HTTP requests to given callback functions
Author: By
Last change:
Date: 5 years ago
Size: 1,180 bytes
 

Contents

Class file image Download

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

For more information send a message to info at phpclasses dot org.