user1032531
user1032531

Reputation: 26281

Execute Slim application middleware before route middleware

According to the documentation http://www.slimframework.com/docs/concepts/middleware.html:

The last middleware layer added is the first to be executed.

According to the same documentation, Slim supports application, route, and group middleware.

I wish to utilize both application and route middleware. The application middleware is for authentication, and should be executed first.

How is this accomplished?

Upvotes: 0

Views: 1352

Answers (1)

tirta keniten
tirta keniten

Reputation: 427

Slim FW allows you to run route before middleware. According to this link, you have to set config/setting determineRouteBeforeAppMiddleware to true.

Here is example code:

<?php

$config = [
    'settings' => [
        'determineRouteBeforeAppMiddleware' => true,
    ],
];
$app = new \Slim\App($config);

Upvotes: 1

Related Questions