I am new to Laminas development. I’m doing a CRUD with Mezzio, based on Mezzio Skeleton. When I edit the routes, to create the edition of some record. I always get a 405 Not Allowed error. If I do the test with Postman if I get results in HTML. Can you tell me what the problem may be?
Thank you.
Hello and welcome to our forums! ![]()
Can you provide your edited routes? Otherwise it is difficult to help.
Hi Froschdesign.
routes.php
return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
$app->get('/dashboard', App\Handler\HomePageHandler::class, 'home');
$app->get(
'/establecimientos',
Establecimientos\Handler\EstablecimientosListHandler::class,
'establecimientos'
);
$app->post(
'/establecimiento-create',
Establecimientos\Handler\EstablecimientosCreateHandler::class,
'establecimiento.create'
);
$app->put(
'/establecimiento-edit/{id:\d+}/',
Establecimientos\Handler\EstablecimientosEditHandler::class,
'establecimiento.put'
);
$app->get(
'/establecimiento-view/{id:\d+}/',
Establecimientos\Handler\EstablecimientosUpdateHandler::class,
'establecimiento.view'
);
$app->patch(
'/establecimiento-edit/{id:\d+}/',
Establecimientos\Handler\EstablecimientosUpdateHandler::class,
'establecimiento.patch'
);
$app->delete(
'/establecimiento-delete/{id:\d+}/',
Establecimientos\Handler\EstablecimientosDeleteHandler::class,
'establecimiento.delete'
);
Thanks your quickly response!!
This looks okay, some paths can be improved.
On which route does the error occur? Maybe if you try to access the post route via a normal browser request without a form?
$app->put(
'/establecimiento-edit/{id:\d+}/',
Establecimientos\Handler\EstablecimientosEditHandler::class,
'establecimiento.put'
);
Here I access through a link like this:
http://127.0.0.1:8088/establecimiento-edit/4
I think that the routes do not understand that it is a PUT request, because when I make the call from postman and I indicate the PUT method, it returns the form
The routes are working but you can not access the PUT request via a simple browser call.
Excuse me, now I have fallen into the call to edit must be GET and PUT the call to save the data. Thanks a lot.