2021-12-30 934次浏览

Both router and its FastRoute adapter went stable. These are very central packages in Yii3.

The package provides PSR-7 compatible request routing and a PSR-15 middleware ready to be used in an application. Instead of implementing routing from ground up, the package provides an interface for configuring routes and could be used with an adapter package. Currently, the only adapter available is FastRoute.

Router has the following features:

  • URL matching and URL generation supporting HTTP methods, hosts, and defaults.
  • Good IDE support for defining routes.
  • Route groups with infinite nesting.
  • Middleware support for both individual routes and groups.
  • Ready to use middleware for route matching.
  • Convenient CurrentRoute service that holds information about last matched route.
  • Out of the box CORS middleware support.

You can find more details in the package readme. A guide-style documentation about Yii3 routing will be available a bit later.

As with other Yii3 packages, we achieved great tests coverage including mutation testing and full static analysis with Psalm strctest level. Such quality standards allow us to build further packages based on the routing with a very high confidence.