Laravel 5 Global Routing Package

Łukasz Piotrowski Comments 0


    Laravel 5 Global Routing gives You possibility making own controllers and access to them via URL.
    Similar feature was released on CakePHP.


    Add dependency to composer.json:

    “require": {
        “pyton/global-routing": “dev-master"

    or run
    composer require pyton/global-routing

    To config/app.php file as last string add:

    ‘providers' => [    
        // …

    It's so important, because this ServiceProvide registers global route which could override some other entries.


    We can access to global route:

    | Domain | Method                         | URI                              |
    |        | GET|HEAD|POST|PUT|PATCH|DELETE | {controller}/{action?}/{params?} |

    URL will bee mapped to:

    namespace App\Http\Controllers;
    class HomeController extends Controller
        public function showAction($id)

    URL -> Controller Conversion Rules

    On Converting URL to Controller/Method there are few Rules:
    {controller} – home -> HomeController (ucfirst + sufix “Controller")
    {action} – show -> showAction (lowercase + sufix “Action")

    Params are separated by /. Params are mapped in the order of in URL.
    Bind param are not override and pass full Bind object ex.::

    public function showAction($id, Request $reques, $id2, $id3)

    Request $request will bind properly Object.


    This is the first release and can have some bugs.
    Post all Your comments and suggestions.


    Other posts