Laravel's routing system for version 8 changed the way the ServiceProvider
. Previously the attribute $namespace
was declared in this way:
protected $namespace = 'App\Http\Controllers';
However, in version 8 the attribute is declared as null.
protected $namespace = null;
So the routes in version 8 must be declared in the following way:
<?php
//Se debe llamar al controllador
use App\Http\Controllers\UserController;
//De esta manera puede ser usado al momento de declarar la ruta.
Route::get('/user', [UserController::class, 'index']);
If you are working on a new project, you may not see much of a problem in adapting to version 8, but if you want to migrate a system in which you have hundreds or thousands of routes, changing all the routes one by one may not be a viable solution.
Can I stay on the old routing system while on Laravel version 8?