The following regex will convert old, closure-based view routes from:
Route::get('faq', function () {
return view('faq');
});
to the new, cacheable Route::view()
introduced in Laravel 5.5.
Route::view('/faq', 'faq');
Check out this tweet for more details.
Route::get\('([^']+)', function \(\) \{\s+return view\('([^']+)'\);\s+\}\)
Note: assumes well-formatted code.
Route::view('/$1', '$2')