Published on
Recently, I created a package for Laravel called Route Redirect Helper, which adds a Route::redirect()
macro to the router so you don’t have to create a closure for each simple redirect in your application.
After using my helper for a bit I noticed that I could simplify something else I do in most projects, which is create a PagesController
to handle all static pages like FAQs, Terms, License, etc.
To reduce the number of overly-simple controllers I have in my applications, I created a new package for Laravel called Route View Helper, which allows me to turn the former into the latter:
Route::get('/terms', function () {
return view('pages.terms');
});
Route::view('/terms', 'pages.terms');
The package uses an internal controller so you can still cache your routes.