Skip to content

Should Slim 4's middleware be LIFO or FIFO? #2408

Description

@akrabat

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:

  1. middleware1
  2. middleware2
  3. 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:

  1. middleware3
  2. middleware2
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions