They are stored in bootstrap/cache w3coded cached framework folder.,Yes, if body of the group is also w3coded cached framework another group or non-closure like route.,Will w3coded cached framework grouped Laravel routes be cached? Where are they w3coded cached framework cached?,The Bootstrap Directory
Closure like group (non cacheable):
Route::group(['middleware' => ['guest'], function() {
Route::get('/hi', function() {
dd('Hi I am closure');
});
});
Non-closure like group
Route::group(['middleware' => ['guest'], function() {
Route::get('/hi', 'WelcomeController@hi');
Route::get('/bye', 'WelcomeController@bye');
});
In fact second example is a closure (obviously) but (my guess is) Laravel will detect the closure contains only another routes (that are "cacheable") and rewrite it behind the scenes to following (this is not precisely correct and Laravel does not rewrite anything its simple demonstration how it might look, in reality Laravel uses Illuminate\Routing\RouteCollection
object):
Route::get('/hi', 'WelcomeController@hi')->middleware('guest');
Route::get('/bye', 'WelcomeController@bye')->middleware('guest');
And this is the code that determines if route is or is not "cacheable" from route.php
public function prepareForSerialization()
{
if ($this->action['uses'] instanceof Closure) {
throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
}
$this->compileRoute();
unset($this->router, $this->container);
}
Last Update : 2023-09-22 UTC 12:24:16 PM
Last Update : 2023-09-22 UTC 12:23:58 PM
Last Update : 2023-09-22 UTC 12:23:51 PM
Last Update : 2023-09-22 UTC 12:23:37 PM
Last Update : 2023-09-22 UTC 12:23:18 PM
Last Update : 2023-09-22 UTC 12:22:38 PM
Last Update : 2023-09-22 UTC 12:22:23 PM