| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 71 | All time: 10,270 This week: 673 | ||||
| Version | License | PHP version | Categories | |||
| php-route 1.0 | The PHP License | 5 | HTTP, PHP 5, Design Patterns |
| Description | Author | ||||||||
This class can call a function when the request matches a pattern. |
|
A PHP Route Class
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']);
| File | Role | Description |
|---|---|---|
| Lic. | License text | |
| Doc. | Documentation | |
| Class | Class source |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% |
|
|
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.