Laroute

Introduction

Laroute, named with Laravel route, is a high readablility route syntax for Laravel.

Defaultly, we define routes of laravel with PHP Route::get, Route::group, ... It's cumbersome and unreadable. When your project becomes more and more complex, it's more and more hard to find what you need in your routes.php or web.php. But now, you have Laroute, your routes file will looks like this.

: >web >otherMiddleware @laroute.fenzland.com +Home: GET / index ()=> view('welcome') GET /login login >guest >>Auth@login POST /login logingin >guest >>Auth@logingin : >auth /user &User resource /foos foos >>Foo resource /readonly readonly * index show >>ReadonlyResource resource /undeletable undeletable - destroy >>UndeletableResource any /closure-example ()=>{ $message="Any method can access this route. That's easy but not good."; return $message; } # this is comment comment

Instead of this.

Route::group([ 'middleware'=>[ 'web', 'otherMiddleware', ], 'domain'=>'laroute.fenzland.com', 'as'=>'Home:', ],function(){ Route::get('/',function(){ return view('welcome'); })->name('index'); Route::get('/login','Auth@login')->middleware('guest')->name('login'); Route::post('/login','Auth@logingin')->middleware('guest')->name('logingin'); Route::group([ 'middleware'=>'auth', 'prefix'=>'/user', 'namespace'=>'User' ],function(){ Route::resource('/foos','Foo',[ 'as'=>'foos', ]); Route::resource('/readonly','ReadonlyResource',[ 'as'=>'readonly', 'only'=>[ 'index', 'show', ], ]); Route::resource('/undeletable','UndeletableResource',[ 'as'=>'undeletable', 'except'=>[ 'destroy', ], ]); }); Route::any('/closure-example',function(){ $message="Any method can access this route. That's easy but not good."; return $message; })->name('closure-example');});

What's more, inclution is available, so your routes do not have to squeeze together into one file any more. Your main route file will be like this.

: >web @ guest : >auth @ authorized : >isVip @ vip : >isAdmin @ admin