Closed ranferi closed 3 years ago
This due to a change in Laravel.
A freshly installed Laravel 8 application now no longer uses controller namespacing - the $namespace
property on the RouteServiceProvider
is not set. This means when referencing controllers when defining routes, you need to fully qualify the controller class name.
In this scenario, this is therefore correct:
->controller(\App\Http\Controllers\OrdersController::class)->routes(function ($orders) {
$orders->get('{record}/completed', 'completed');
})
@lindyhopchris again, thank you!!
Hi. I'm trying to extend a controller for my 'orders' resource to add a new action 'completed'. But when I added the method
controller()
to the route and I runphp artisan route:list
, it send this error (I'm using laravel-json-api version 3.2.0):Target class [OrdersController] does not exist
this is my configuration in api.php:
But if I added the controller like this, it works
My configuration in my json-api-v1.php it's not that different from the default file (i think a set 'url' to adapt to my api route):
and my controller looks like this:
Another thing I tried, before using the complete path to the controllers, was to change the controller to another namespace ('Api', 'api', 'Api\V1') and didn't work.
It's there something I'm missing in my config that causes this problem of the missing controller?