Method Overriding Middleware

The Method Overriding Middleware enables you to use the X-Http-Method-Override request header or the request body parameter _METHOD to override an incoming request’s method. The middleware should be placed after the routing middleware has been added.



use Slim\Factory\AppFactory;
use Slim\Middleware\MethodOverrideMiddleware;

require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

// Add RoutingMiddleware before we add the MethodOverrideMiddleware so the method is overridden before routing is done

// Add MethodOverride middleware
$methodOverrideMiddleware = new MethodOverrideMiddleware();

// ...