Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2022-02-19 (11 months ago)  | | Not yet rated by the users | | Total: 68 | | All time: 10,110 This week: 189 |
|
Description | | Author |
This class can call a function when the request matches a pattern.
It can register regular expressions to match the current HTTP request URI.
The class can associate each regular expression to a given callback function.
It can also check if any of the registered regular expressions. The first regular expression that matches the URL of the current HTTP request will make the class call the associated callback function. | |
|
Details
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']);
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.