开发者

Symfony: Special routing for mobile browsers

开发者 https://www.devze.com 2022-12-23 14:25 出处:网络
Is there any way that I can detect browser type on routing and use specific controller? I want to be able to do something like this in routing.yml:

Is there any way that I can detect browser type on routing and use specific controller? I want to be able to do something like this in routing.yml:

mobile:
  url:   /*
  requirements:
    brows开发者_如何学Goer: mobile


This symfony blog article from Fabien describes an elegant solution for an iPhone-optimised version of your website. Change the regexp he uses to something that more broadly matches the browsers/clients used to access your site, and you have a 'mobile' version.

EDIT: I would add that perhaps a different 'app' altogether might be a better solution, a la Facebook's m.facebook.com interface.


Not really quite what you are after, but you could use the scripts from http://detectmobilebrowsers.mobi/ to detect what type of browser a request is coming from. You might they be able to integrate these scripts into a base controller (or router) class to handle requests appropriately.

0

精彩评论

暂无评论...
验证码 换一张
取 消