I am trying to create a website that will have the following
- Web Access
- Android/iPhone Mobile app accessing API
- Mobile Web
I want all the above three to access the same webroot and resources in terms of Images.
the URL will be
- site.com
- api.site.com
- m.site.com
may be an alternative touchscreen site at touch.site.com
How can I have CakePHP handle all these in one installation?
The best thing to do is to use prefixes. Internally your URLs will be routed like
/api/controller/actionto an action calledapi_action. You can switch layouts/authentication/whatever logic in your beforeFilters depending on the prefix ($this->params['prefix']).For handling this as subdomains you just have to do some internal .htaccess rewriting to change URLs from
api.example.com/to yourexample.com/apiprefix. To properly reverse-route links, you’re probably best off implementing a custom RouteClass. Look at the default CakeRoute class for guidance.