Have you tried php artisan route:clear after making the changes?
Also, composer dump-autoload is sometimes needed.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello All,
I just have a small question. Laravel is behaving strange (in my opinion :-) ). And I don't now why.
I was struggling for more than a day, just to get a route working. I know Laravel change it logic but still I don't understand.
My question is: Why is /admins and /users working, and if I change these into /admin or /user is give me the "Target class [DemoController] does not exist"
It is just in fresh install of laravel, and these the only routes I have except the default welcome one.
I just want to understand, why the plural is working and the singular not.
Kr esorone
Route::get('/admins', 'App\Http\Controllers\DemoController@adminDemo'); => WORKS
Route::get('/admin', 'App\Http\Controllers\DemoController@adminDemo'); => NOT WORKING
Route::get('/users', 'App\Http\Controllers\DemoController@userDemo'); => WORKS
Route::get('/user', 'App\Http\Controllers\DemoController@userDemo'); => NOT WORKING
I can't reproduce the behaviour. It works fine for me - Laravel 8 fresh install.
Do you have any namespace set in your RouteServiceProvider?
Have you tried the new tuple syntax?
e.g.
Route::get('/admin', [DemoController::class, 'adminDemo']);
Route::get('/admins', [DemoController::class, 'adminDemo']);
Route::get('/users', [DemoController::class, 'adminDemo']);
Route::get('/user',[DemoController::class, 'adminDemo']);
Remembering to import DemoController.
Please or to participate in this conversation.