I have just installed Laravel 8 and created a fresh new app. I didn't change any file except web.php and added IndexController.php. In web.php the only code I have is: <?php
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Controllers;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [IndexController::class, 'index']);
In IndexController.php I have:
<?php
namespace Illuminate\Http\Controllers;
use Illuminate\Http\Request;
class IndexController extends Controller
{
//
public function index()
{
return 'This is a controller';
}
}
If I go to localhost:8000 it throws Target class [IndexController] does not exist. I've tried everything that it is to try: modify RouteServiceProvider.php, clear cache, delete IndexController and recreate it. Nothing. I'm still getting the same message.