From 7863df6325d971b9ff63d0c1ae0fad357eee257e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Tue, 20 Oct 2015 23:59:35 +0200 Subject: [PATCH] [TASK] Updated readme --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3867cb4..ecb598c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ Add the latest version pf Simple PHP Router to your ```composer.json``` - Sub-Domain Routing - CSRF Protection - Optinal/required parameters +- Aliases for ```RouterRoute``` + +### Known issues + +- Posting invalid/unsupported request-type throws 404 instead of "method not allowed" exception, unless defined within a group. ## Initialising the router @@ -44,7 +49,7 @@ SimpleRouter::init($defaultControllerNamespace); ``` ## Adding routes -Remember the ```routes.php``` file you required in your ```index.php```? This file will contain all your custom rules for routing. +Remember the ```routes.php``` file you required in your ```index.php```? This file will contain all your custom rules for routing. This router is heavily inspired by the Laravel 5.* router, so anything you find in the Laravel documentation should work here as well. ### Basic example @@ -54,8 +59,8 @@ use Pecee\SimpleRouter\SimpleRouter; /* * This route will match the url /v1/services/answers/1/ - - * The middleware is just a class that renders before the + + * The middleware is just a class that renders before the * Controller or callback is loaded. This is useful for stopping * the request, for instance if a user is not authenticated. */ @@ -66,13 +71,13 @@ SimpleRouter::group(['prefix' => 'v1', 'middleware' => '\MyWebsite\Middleware\So SimpleRouter::get('/answers/{id}', 'ControllerAnswers@show') ->where(['id' => '[0-9]+'); - + // 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'); @@ -84,7 +89,7 @@ SimpleRouter::group(['prefix' => 'v1', 'middleware' => '\MyWebsite\Middleware\So ### Doing it the object oriented (hardcore) way -The ```SimpleRouter``` class referenced in the previous example, is just a simple helper class that knows how to communicate with the ```RouterBase``` class. +The ```SimpleRouter``` class referenced in the previous example, is just a simple helper class that knows how to communicate with the ```RouterBase``` class. If you are up for a challenge, want the full control or simply just want to create your own ```Router``` helper class, this example is for you. ```php @@ -171,7 +176,7 @@ In ```routes.php``` we have added this route: In the template we then call: -```url('myController@show', ['id' => 22], ['category' => 'shoes']);``` +```url('myController@show', ['id' => 22], ['category' => 'shoes']);``` Result url is: @@ -183,4 +188,4 @@ While I work on a better documentation, please refer to the Laravel 5 routing do http://laravel.com/docs/5.1/routing ## Easily extendable -The router can be easily extended to customize your needs. +The router can be easily extended to customize your needs.