I got some doubt on how to perfectly configure and setup a service using Yii and subdomains. Here follows the problem:
I want to be able to provide the service to my clients so that they can run their own istance of the service thourgh customer.mydomain.com. Connecting to this domain the app should load the specific customer’s instance of the service (content and theme).
On my dbschema the customer is modeled as and entity with all his related content. So suppose that each customer can provide some articles running on a customized layout, how I should find a way to have all this working? Can I do it all just using the urlManager?
In this case I cant understand how to make it working cause I should retrieve the customer instance from DB before resolving the url to have something like
I’m sure someone will come over the top of me with a more elegant solution, but I’ll lend my 2 cents. From the sound of things, each URL should resolve to the same action & controller, is that correct?
The urlManager should handle that out of the box. All that remains is retrieving the customer id from the subdomain and making that information available to your controller (so it knows what articles to pull), in which case you could simply just extend the Controller class (or edit it).
i.e. create a public $customer data value in your base Controller class and create an init() function which queries your database for the customer details (and sets the theme/layout if need be).