nikic / FastRoute

Fast request router for PHP
Other
5.13k stars 444 forks source link

如何 同一个url, 根据pc或者h5来使用不同的控制器。 达到显示不同的内容 ? #290

Closed gg22mm closed 4 months ago

gg22mm commented 4 months ago

如何 同一个url, 根据pc或者h5来使用不同的控制器。 达到显示不同的内容 ? How to use different controllers for the same URL based on PC or H5. To display different content?

BX}O140ZQ8Y6FVMV3NTR1GP

如何能达到上面的效果呢? How can we achieve the above effect?

lcobucci commented 4 months ago

You won't be able to achieve that as part of the route registration, as you don't have the context of the request.

You should rather point to a single handler and differentiate the flows there.

You may also consider using Laminas Mezzio or SlimPHP to have tools like middleware to make your process easier (you can still use FastRoute under the hood).