suncat2000 / MobileDetectBundle

Symfony 2/3/4 bundle for detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
398 stars 153 forks source link

some questions #49

Closed mj-bdl closed 10 years ago

mj-bdl commented 10 years ago

I am trying to use the MobileDetectBundle for my pc Symfony2 application, which is already done. What I want to do is that the user can do some of the functionality the pc app does using his/her mobile. So, I think the steps I need to do are the following ones:

1) Create a new bundle called MobileBundle, in which I will use the necessary entities already created in other bundles used for the pc app. 2) Create Controller an Views in that MobileBundle to do the functionality of the mobile app (maybe reuse some functions from other Controllers in other bundles) 3) Using MobileDetectBundle, detect in mi indexAction() (defined in mi StaticBundle) whether the user is accessing the app using a pc or a mobile, and redirect to the appropiate view/controller.

Is this a correct way to do what I need? I have already installed the MobileDetectBundle, but I don't really know how to set the mobile_detect in config.yml. Do I need to create any other .yml config file?

Any help will be welcome.

netmikey commented 10 years ago

You're correct about 1) and 2). Instead of 3), have a look at this chapter: https://github.com/suncat2000/MobileDetectBundle#usage-example in the readme. You'll basically create a new subdomain like m.mydomain.com and point it to a new app_mobile.php entry point. This new entry point will get its own symfony config, where you'll basically just disable the MobileDetectBundle redirection to avoid infinite loop redirections.

That's it. The rest is handled by the bundle. No need to touch your actions, as the bundle will define listeners that will hook into your request lifecycle and do their thing :)