3

I'm currently working on a client proposal which is for a web and a mobile web application both. There are 61 features for the Web application and the Mobile web application is supposed to have a subset of all features.

We evaluated various programming language stacks and decided that LAMP is the best one for this. We even went further and evaluated various MVC frameworks in PHP and finalized YII.

Now my problem here is this. We're going to use the same code-base for the mobile and the Web application. We have planned to route all requests through a "Front-Controller" target Controller that check the "User-Agent" header and has all application controllers in a switch block. So for both the Web and mobile application, the "Model" and "Controller" code remains the same, only the "View" changes. Depending upon the "user-agent", the target controller decides to load the appropriate "View". How does this architecture sound to you all? Does anyone have a better idea? Is this architecture functionally possible in YII? Please guide me about the same.

1
  • If my answer was what you needed, I'd appreciate an up vote. Thanks! Commented Apr 9, 2012 at 13:03

2 Answers 2

3

Sounds like a good and common solution. Here is a blog post on howto switch themes based on browser type:

http://learnyii.blogspot.com/2011/03/yii-theme-iphone-android-blackberry.html

Sign up to request clarification or add additional context in comments.

Comments

3

We have planned to route all requests through a "Front-Controller" target Controller that check the "User-Agent" header and has all application controllers in a switch block

Instead of doing this, consider using a filter instead: http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#filter

They're way more powerful and can eliminate things like switch blocks while still allowing you total control over what theme gets loaded, etc

2 Comments

@verisimilitude: so I gather they were useful? :-)
Yes. I have used Filters in my code (although to serve a different purpose) not the one mentioned above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.