LMSouq
php-dev Open

Error “Target class controller does not exist” when using Laravel 8

NG
Nguyễn Việt Dũng
1 month ago
3 views
Problem Description
**Here is my controller:** <?php namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; class RegisterController extends Controller { public function register(Request $request) { dd('aa'); } } As seen in the screenshot, the class exists and is in the correct place: [![Enter image description here][1]][1] **My `api.php` route:** Route::get('register', 'Api\RegisterController@register'); When I hit my `register` route using [Postman][2], it gave me the following error: > Target class [Api\RegisterController] does not exist. How can I fix it? --- Thanks to the answers, I was able to fix it. I decided to use the fully qualified class name for this route, but there are other options as described in the answers. Route::get('register', 'App\Http\Controllers\Api\RegisterController@register'); [1]: https://i.sstatic.net/H4CtY.png [2]: https://stackoverflow.com/tags/postman/info

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base