Routing In Laravel 8 - Be aware of this major change
Routing In Laravel 8 - A major change you need to know.
With the latest release of Laravel, routing has been changed. We no longer can write routes the old Laravel way, since its latest release that is Laravel 8.
The old way:
Route::get("get-data", "MainController@getData");
Routing in new Laravel 8 way:
use App\Http\Controllers\MainController;
Route::get('get-data', [MainController::class, 'getData']);
In Laravel 8 routing, there are 2 changes,
i) The syntax in the second param of the Route function, we should pass an array with the Controller name and its method and
ii) To import every controller used at the top of the file.
So make sure you are aware of this change.
Link: