target class controller does not exist laravel 8 code example

Example 1: Target class [Controller] does not exist.

//accessing any function in the controller (this is web.php file)
use App\Http\Controllers\PostsController;

Route::get('/post', 'App\Http\Controllers\PostsController@index');

Example 2: laravel target class does not exist

Uncomment this line in app>>provider>>RouteServiceProvider.php file
// protected $namespace = 'App\\Http\\Controllers';

Example 3: Target class [Controller] does not exist.

Route::get('/users', [UserController::class, 'index']);

Tags:

Php Example