mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 21:12:14 +00:00
Merge branch 'master' of https://github.com/skipperbent/simple-php-router
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# [WIP] Simple PHP router
|
# Simple PHP router
|
||||||
Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.
|
Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.
|
||||||
|
|
||||||
**Please note: this project has just been added and is still a work in progress. Please use with caution until a stable release version is available :)**
|
**Please note: this project has just been added and is still a work in progress. Please use with caution until a stable release version is available :)**
|
||||||
@@ -58,6 +58,17 @@ SimpleRouter::group(['prefix' => 'v1', 'middleware' => '\MyWebsite\Middleware\So
|
|||||||
|
|
||||||
SimpleRouter::get('/answers/{id}', 'ControllerAnswers@show');
|
SimpleRouter::get('/answers/{id}', 'ControllerAnswers@show');
|
||||||
|
|
||||||
|
// Resetful ressource
|
||||||
|
SimpleRouter::ressource('/rest', 'ControllerRessource');
|
||||||
|
|
||||||
|
// Load the entire controller (where url matches method names - getIndex(), postIndex() etc)
|
||||||
|
SimpleRouter::controller('/controller', 'ControllerDefault');
|
||||||
|
|
||||||
|
// Example of providing callback instead of Controller
|
||||||
|
SimpleRouter::get('/something', function() {
|
||||||
|
die('Callback example');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -147,7 +158,7 @@ function url($controller, $parameters = null, $getParams = null) {
|
|||||||
|
|
||||||
In ```routes.php``` we have added this route:
|
In ```routes.php``` we have added this route:
|
||||||
|
|
||||||
```Router::get('/item/{id}', 'myController@show');```
|
```SimpleRouter::get('/item/{id}', 'myController@show');```
|
||||||
|
|
||||||
In the template we then call:
|
In the template we then call:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user