Within a Laravel project, I want to create a POST /movies route associated with a controller that has been created with its model:
sail artisan make:model --controller --api --requests -- Movie
which has created among others the POST Form Request Validator (cf documentation Laravel 10.x) StoreMovieRequest and the controller MovieController with among others the store method:
public function store(StoreMovieRequest $request)
Finally, I declared the route within routes/api.php:
Route::post('/movies', [MovieController::class, 'store']);
But I only got a 404 Not Found, while this dummy route would succeeds:
Route::post('/movies', fn () => 'not implemented yet');
I tried many variation of the route declaration, they all produced a 404 Not Found:
Route::controller(MovieController::class)->group(function () {
Route::get('/movies', 'index');
Route::get('/movies/{id}', 'show');
Route::post('/movies', 'store');
Route::put('/movies/{id}', 'update');
Route::delete('/movies/{id}', 'destroy');
}); // 404
Route::post('movies', [MovieController::class, 'store']); // 404
Route::resource('movies', MovieController::class); // 404
Route::apiResource('movies', MovieController::class); // 404
I checked for many possible bug: bad namespace, bad file name, conflicting file name, etc. nothing has worked.
I found many stackoverflow potentially related to my problem, but none has solved this problem:
