Home > Enterprise >  My fresh Laravel 9 app cannot see a controller
My fresh Laravel 9 app cannot see a controller

Time:02-11

I have a fresh instance of Laravel 9. I am migrating all my controllers from an old Laravel 8 application. My problem is that the app cannot see the controller.

Target class [AdminToolsController] does not exist.

web.php

Route::get('/php', 'AdminToolsController@php');

Controller

public function php() 
{
    $laravel = app();
    echo "Your Laravel version is ".$laravel::VERSION;
    echo phpinfo();
}

CodePudding user response:

The syntax for routes has been Route::get(uri, [controller, action]) for some time now. It's not a laravel 9 thing

use App\Http\Controllers\AdminToolsController;

Route::get('/php', [AdminToolsController::class, 'php']);

or

Route::get('/php', [\App\Http\Controllers\AdminToolsController::class, 'php']);
  • Related