Routing Middleware

The routing has been implemented as middleware. We are still using FastRoute as the default router but it is not tightly coupled to it.If you wanted to implement another routing library you could by creating your own implementations of the routing interfaces. DispatcherInterface, RouteCollectorInterface, RouteParserInterface and RouteResolverInterface which create a bridge between Slim’s components and the routing library.If you were using determineRouteBeforeAppMiddleware, you need to add the Middleware\RoutingMiddleware middleware to your application just before your call run() to maintain the previous behaviour.

Usage

  1. <?php
  2. use Slim\Factory\AppFactory;
  3. require __DIR__ . '/../vendor/autoload.php';
  4. $app = AppFactory::create();
  5. // Add Routing Middleware
  6. $app->addRoutingMiddleware();
  7. // ...
  8. $app->run();