-5

I have a question about Laravel, I install Laravel 8 but the routes doen't work anymore. Can anyone help me about this problem? I tried to do the routes different but that doesn't work.

  • If you have worked with previous versions, the route syntax has been changed. Read the [documentation](https://laravel.com/docs/8.x/routing). – Rouhollah Mazarei Sep 16 '20 at 07:56
  • you can check my answer about this https://stackoverflow.com/questions/63882034/target-class-does-not-exist-problem-in-laravel-8 – Kamlesh Paul Sep 16 '20 at 08:22
  • Does this answer your question? [Target class controller does not exist - Laravel 8](https://stackoverflow.com/questions/63807930/target-class-controller-does-not-exist-laravel-8) – miken32 Jul 19 '21 at 16:08

3 Answers3

0

add $namespace to App/Providers/RouteServiceProvider.php

protected $namespace = 'App\Http\Controllers';

also add namespace to boot function

    Route::middleware('web')
        ->namespace($this->namespace) 
        ->group(base_path('routes/web.php'));

    Route::prefix('api')
        ->middleware('api')
        ->namespace($this->namespace) 
        ->group(base_path('routes/api.php'));
-1

in laravel 8 you can't use controller in web.php without adding namespace here is the example from my web.php web.php

use App\Http\Controllers\YourController;

Route::get('/url', [YourController::class, 'method']);
or
Route::get('/url','App\Http\Controllers\YourController@method');
-1

Pls have a look at official documentation, this can be helpful routing is now updated

https://laravel.com/docs/8.x/routing

Muhammad Tariq
  • 175
  • 1
  • 11