Send a form using PUT instead of POST

I was wondering whether it’s possible to submit a form using a method other than POST in Slim, for example PUT, PATCH, etc.

With Laravel, you can use the @method('PATCH') directive, which adds the necessary information to the form, and then use patch() instead of post() in the router.

Add the MethodOverrideMiddleware and use _METHOD hidden element, or set the X-Http-Method-Override header.

See Method Overriding Middleware - Slim Framework

Worth adding: the form itself still needs method=“POST”, since HTML forms only support GET and POST — the hidden _METHOD field (or the X-Http-Method-Override header) only tells Slim what the real verb is. Register MethodOverrideMiddleware so it runs before route matching, and define the route with $app->put() / $app->patch() as usual. The header variant is handy for fetch/AJAX calls where you can set headers directly.