Hello all, I’m rying to follow this tutorial to learn slim.
Everything works fine until i start to use the first post route. Chapter 35:44 - New record endpoint
All other routes work perfectly fine (get routes):
$app->get('/api/users', UserIndex::class);
$app->get('/api/users/{id:[0-9]+}', Users::class . ':show')->add(GetUser::class);
$app->post('/api/users', [Users::class, 'create']);
All classes are in use statements at the top.
This is the error Message I get, when I want to access the /api/users post route:
404 Not Found
The application could not run because of the following error:
Details
Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: /var/www/html/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php
Line: 76
Trace
#0 /var/www/html/vendor/slim/slim/Slim/Routing/RouteRunner.php(56): Slim\Middleware\RoutingMiddleware->performRouting(Object(Nyholm\Psr7\ServerRequest)) #1 /var/www/html/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Slim\Routing\RouteRunner->handle(Object(Nyholm\Psr7\ServerRequest)) #2 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(Nyholm\Psr7\ServerRequest), Object(Slim\Routing\RouteRunner)) #3 /var/www/html/src/App/Middleware/AddJsonResponseHeader.php(13): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest)) #4 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(269): App\Middleware\AddJsonResponseHeader->__invoke(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous)) #5 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest)) #6 /var/www/html/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #7 /var/www/html/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(Nyholm\Psr7\ServerRequest)) #8 /var/www/html/public/index.php(56): Slim\App->run() #9 {main}
What am I doing wrong?
Thanks for any help
Jevy