write your api routes on api.php, for example
use App\Http\Controllers\Api\ApiController;
Route::get('employees', [ApiController::class, 'index']);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi i am trying declare a api resource route with array syntax like this https://laravel.com/docs/8.x/controllers#api-resource-routes
Route::apiResource('segments', SegmentController::class);
But this does not work and i get an strange error saying it can not find the class. But in the error the path to class is duplicated. My class is at Project\Http\Controllers\SW\V1\SegmentController but laravel looking to find the class in Project\Http\Controllers\SW\V1\Project\Http\Controllers\SW\V1\SegmentController . I am not sure what i am doing wrong. If anyone can help with any insight that would be very helpul. Thanks in advance.
Check your RouteServiceProvider. You might have the namespace specified in there as well.
Please or to participate in this conversation.