I want to use the Laravel 9 route namespace function and I wonder how to pass the namespace correctly?
Route::as('some.')->namespace('AppHttpControllersApiV1')->group(function() {
Route::post('/store', [SomeController::class, 'store'])
->name('store');
});
I get the following error message:
"message": "Target class [SomeController] does not exist.",
"exception": "IlluminateContractsContainerBindingResolutionException",
Question: How do I do this properly?
But this works
Route::as('some.')->group(function() {
Route::post('/store', [AppHttpControllersApiV1SomeController::class, 'store'])
->name('store');
});
3
Answers
Well, you need to provide the right path to the controller file. For example at the top of the file put this:
use AppHttpControllersController;
use it :
Since you are using a namespace for route,so you should use
Ref: https://laravel.com/docs/8.x/releases#routing-namespace-updates