Multiple applications into a single one, accessing resources.

Here is the thing, i took a look at: in order to implement for my CMS, but i gave up because it simply doesn’t work as expected, to much waste of time trying to understand it, and beside this, important things like having the assets all together shared between the apps, or making the runtime folder common to all apps are not treated at all.

Anyway, going back to my issue, i create my own structure, basically i have 3 apps in a single one

front app/admin app/common app

The common folder will hold files used between the front and admin, now i managed to figure out the assets/runtime/base url/general config and everything is working great with a single exception:

If for example, i am in admin and i need to generate a frontend url, it becomes a bit of a pain, that’s because the frontend has a confguration file, the admin another one and the common folder has the base to these two, and, when the admin app is running it has no way to know the url rules for frontend, and because of that, i have to declare these rules in the common configuration, but even if i am doing like so, the urls are generated with /admin/ in front because they are generated from the admin app and not from the frontend.

I have a temporary solution for this:

public static function createFrontendUrl($url, $params=array(), $absolute=false)


        // get the current base url

        $thisBaseUrl = Yii::app()->urlManager->getBaseUrl();

        // find the frontend base url.

        $frontEndBaseUrl = str_replace('/admin', '', $thisBaseUrl);

        // temporary set the base url for frontend.


        // create the url


            $url=Yii::app()->createUrl($url, $params);


            $url=Yii::app()->createAbsoluteUrl($url, $params);

        // put back the original url


        // return the generated one.

        return $url;


Which works just fine for now, but i was wondering, is there a better way of doing this ?

Hope the above explanation makes sense.