I'm creating an application that needs to be duplicated for every client my company earns. The reason the whole application needs to be duplicated is because each client may need "special customizations". On the other hand, many components will not be changed so I would like these to be shared. Also, there are the "company pages" which should share e.g. the layout with the client applications. So I think this route it the best:
However, I need a way to forward the requests to the right application. For instance /banana/controller/action should forward to the banana application physically located under protected/banana but keep the controller/action values.
Where should this logic take place? Perhaps in index.php? How can I access the request (/banana/controller/action) and parse it from in there?
So I figure my index.php should look something like this:
<?php
require_once('../yiiRepo/framework/yii.php');
$applications = array( //can be manually managed
'banana',
'tomato'
);
$firstPartOfUrl = ??; //should come out to banana if we are requesting /banana/post/create
if (isset($applications[$firstPartOfUrl])) { //then we are requesting a client application
$application = $firstPartOfUrl;
//now do modification so the app knows that we are requesting the post controller and create action?
}
Yii::createWebApplication('protected/'.$application.'/config/main.php')->run();
I'm kinda stuck on how to do this. Basically it would be like the module system that Yii currently has, but instead of modules, it's embedded apps. I think this would be more appropriate for this case.
Or would something with .htaccess be better (I'm not as proficient with RewriteEngine)?
I think for now I'm actually going to go a conservative route and have all clients under one application that supports them all. There are both drawbacks and bonuses for this it seems…
Quick question (I think)
I want to intercept all controller requests that fail
For instance, a request to /banana would initially seem to fail because there is no banana controller. But before giving the client the error page, I would like it to first check if ‘banana’ is stored in a database table that I have, and if so, it should redirect (an internal redirect, preferably) to /clients/register/company/banana
If this is currently possible with Yii, i'm guessing it's some class I need to extend somewhere… any pointers to where to start?
I considered modules but I didn't seem like an option because of this behavior:
When looking for a component (or controller, module, etc), first it looks in the main application and THEN it looks in the module. I need it the other way around, so I can override and make special changes to different components. For now I am going a different route though.
When looking for a component (or controller, module, etc), first it looks in the main application and THEN it looks in the module. I need it the other way around, so I can override and make special changes to different components.
Is that really a problem? My customized components (even the overrieded ones) reside inside modules. In main application remains just the shared resources.