E
E
eternal_blue2020-09-09 16:32:19
Laravel
eternal_blue, 2020-09-09 16:32:19

Why does laravel say the class doesn't exist if it exists?

Hello, I am new to laravel, I just sat down to master this framework and immediately got an annoying error. Says that the TestController controller does not exist, although it certainly does.

web.php: App/Http/Controllers/TestController.php:
Route::get('test/show', '[email protected]');

namespace App\Http\Controllers;
  use App\Http\Controllers\Controller;
  
  class TestController extends Controller
  {
    public function show()
    {
      return 'TestController';
    }
  }

What could be wrong here?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rst630, 2020-09-09
@rst630

Above correctly wrote composer dump-autoloaddo it.
In order not to do this manually every time - create controllers and so on through artisan, then everything will be created
for the controller php artisan make:controller TestControllerand connected to autoload by itself.
php artisan help makelook what he can create

S
Sanes, 2020-09-09
@Sanes

  1. Try clearing cachephp artisan optimize:clear
  2. Check file/directory permissions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question