How to write

Slim application middleware must subclass \Slim\Middleware and implement a public call() method. The call()method does not accept arguments. Middleware may implement its own constructor, properties, and methods. I encourageyou to look at Slim’s built-in middleware for working examples (e.g. Slim/Middleware/ContentTypes.php orSlim/Middleware/SessionCookie.php).

This example is the most simple implementation of Slim application middleware. It extends \Slim\Middleware,implements a public call() method, and calls the next inner middleware.

  1. <?php
  2. class MyMiddleware extends \Slim\Middleware
  3. {
  4. public function call()
  5. {
  6. $this->next->call();
  7. }
  8. }