Download the PHP package jetwaves/laravel-implicit-router without Composer
On this page you can find all versions of the php package jetwaves/laravel-implicit-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jetwaves/laravel-implicit-router
More information about jetwaves/laravel-implicit-router
Files in jetwaves/laravel-implicit-router
Package laravel-implicit-router
Short Description A simple Implicit Router/Controller Router for Laravel whose version >= 5.2 ( 5.5 tested )
License MIT
Informations about the package laravel-implicit-router
laravel-implicit-router
A simple Implicit Implicit Router/ Controller Router for Laravel whose version >= 5.2 ( 5.5 tested )
CREDIT TO dingo/api and laravel framework
HOW TO USE:
(exemple tested working well in Laravel 5.5 / should be the same in Laravel 5.2 5.3 5.4 )
Situation:
From Laravel 5.2, the feature implicit controller routing has been removed.
But some projects have thousands of routing rules to declare.
Solution:
-
run command:
-
in your api.php or web.php in routes, add this following lines (1).
-
in your App/Http/Controllers/TestController.php, add a function like
-
then we can access this controller by http://hostname/URI_PREFIX/show-me-the-money and get the following response in your browser. Just like the implicit controller routing of Laravel 5.1 at old time.
10000 gold
- All Http method keywords are allowed to be the prefix of Camel Type function name to serve correspondent http methods.
- When function does not exists, you'll get a 404 of laravel itself.
- Declare explicit routes in the original way. (nothing changed)
Middleware support:
code snippet (1) could be used in a closure of middlewares.
when the 'test' middleware do
and you access http://hostname/URI_PREFIX/show-me-the-money, you'il get
starcraft tricks : 10000 gold
in browser.
Probably a ungraceful solution but save your time and life. :-)
TODO:
- Support some frequently used 'native' middleware declarations, in the line of route declaration.
- Beautify the php source code and this readme file.
- Make it functional for lumen.
- Show me your stars 8-D .