Skip to content

developerdevice/PHP-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

PHP-route

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";
});
Router::execute($_SERVER['REQUEST_URI']);

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}';
});
Router::execute($_SERVER['REQUEST_URI']);

About

A PHP Route Class

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages