I'm using CodeIgniter to develop a new web app, and I'd like to create a mobile version that users get redirect to when they visit it from their phones.
The mobile version of the app should have a different flow, so swapping CSS/HTML files in the code is not an option for me since the mobile version and the web version will handle things differently in their Controllers and Views, while sharing the same Models.
Anyway how I could do this efficiently?
Your help is much appreciated. :)
If you really need 2 independant apps, you can setup this with juste one or two codeigniter core modification, depending if you're using PHP4 or 5.
We've done it following this CI's wiki page and it works great, we share models, libraries, configuration. Basically you got a project organization like this :
/application/
/common/<similar to application directory, but used for shared libs/helper/models/configs files>
/frontend/<similar to application directory>
/backend/<similar to application directory>
/system/
By overriding loaders you can implement loading priority if the same lib/config is present for common classes or app-specific). Also you can move all common code (controllers, specific routing class, etc.) and keep only application specific overloadings in your apps.
In the end you got two Front Controllers (mostly identical to the index.php file) one for each app, and you're free to filter visitors with url rewriting, specific subdomain, etc.
If you're targeting servers running PHP4, I opened this thread on codeigniter forums to see what to change in core classes to get it to work (without modification there is a loading issue)
Another viable alternative, but I haven't used it yet, is using HMVC organisation
Solution (a):
Note: (a) becomes messy if your application grows over the time.
Solution (b):
Any of the above required (extensive?) modification of the CI framework. Try to do as much as possible by overwriting the existing classes (MY_Controller etc.) to be able to update at a later time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With