Back

L5 group:prefix routes when running php artisan route:clear


illuminate3 posted 3 years ago
Route::group(['prefix' => 'admin'], function() {
	Route::get('/', function() {
		dd('loaded');
	});
});

Basically straight out of the documentation.

When I run php artisan route:clear the error I'm getting is

exception 'LogicException' with message 'Unable to prepare route [admin] for serialization. Uses Closure.'

I don't have any code for the admin section yet but I doubt that is the issue.

Any ideas?

thanks!

mackiecarr replied 3 years ago Solution

You can cannot cache routes that use Closure's.

"If your application is exclusively using controller routes, you may take advantage of Laravel's route cache.".

You must have already cached your routes then added a new one with a Closure which would give you that error when you go to clear the route cache to generate a new one.

You can do the following though:

Route::group(['prefix' => 'admin'], function() {
    Route::get('/', '[email protected]');
});
illuminate3 replied 3 years ago

Thanks

I wouldn't have thought of looking under controllers for that information.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us