Slim 3 currently uses a Last In, First Out (LIFO) model for middleware.
That is:
$app->add('middleware3');
$app->add('middleware2');
$app->add('middleware1');
will execute the middleware in the order:
- middleware1
- middleware2
- middleware3
This works if you imagine middleware as layers of an onion and adding a new middleware adds a new layer to the outside of the onion.
An alternative, would be to use First In, First Out (FIFO) model.
This is, the same PHP code would execute the middleware in this order:
- middleware3
- middleware2
- middleware1
This works if you imagine middleware as a pipleline going from top to bottom where the first one you add is the first one that's executed, then the second one added is executed, etc.
Should Slim 4 change to the FIFO model?
Slim 3 currently uses a Last In, First Out (LIFO) model for middleware.
That is:
will execute the middleware in the order:
This works if you imagine middleware as layers of an onion and adding a new middleware adds a new layer to the outside of the onion.
An alternative, would be to use First In, First Out (FIFO) model.
This is, the same PHP code would execute the middleware in this order:
This works if you imagine middleware as a pipleline going from top to bottom where the first one you add is the first one that's executed, then the second one added is executed, etc.
Should Slim 4 change to the FIFO model?