💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 路由的中间件 The routing has been implemented as middleware. We are still using[FastRoute](https://github.com/nikic/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. > 路由已作为中间件实现。我们仍然使用[FastRoute](https://github.com/nikic/FastRoute)作为默认路由器,但它并没有与之紧密耦合。 > 如果希望实现另一个路由库,可以创建自己的路由接口实现。`DispatcherInterface`,`RouteCollectorInterface`,`RouteParserInterface`and`RouteResolverInterface`在Slim的组件和路由库之间建立了一座桥梁。如果您使用的是`Middleware\RoutingMiddleware`,那么您需要在调用run()之前将中间件路由中间件添加到您的应用程序中,以维护先前的行为。如果您使用的是`determineRouteBeforeAppMiddleware`,您需要在您的调用run()之前将`Middleware\RoutingMiddleware`中间件添加到您的应用程序中,以保持先前的行为。 ## Usage ~~~php <?php use Slim\Factory\AppFactory; require __DIR__ . '/../vendor/autoload.php'; $app = AppFactory::create(); // Add Routing Middleware $app->addRoutingMiddleware(); // ... $app->run(); ~~~