PHP Classes


Recommend this page to a friend!
  Classes of Mauro Junior   PHP Router Class   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Router Class
Call a function when the request matches a pattern
Author: By
Last change:
Date: 11 months ago
Size: 748 bytes


Class file image Download


A PHP Route Class

How to use ?

To use PHP Router Class you need to clone our repository. Considering you've already made it, make a file .php as you preferer.

This example doesn't use PSR4/0 however we are using namespace, i recommend you to keep it.

Put the code below in your file .php

use \Src\Core\Router;

Router::route('/', function(){	
  echo "You're in home page";

To every created router you need re-execute the router as you seen above. The next example show how you can use regex pattern.

use \Src\Core\Router;

Router::route("/(\w+)/", function($id){	
  echo 'My id is: {$id}';