views:

42

answers:

1

Hey all, kind of new at Kohana and I have a quick question.

I have a site where there will be three subsections, organized by subdomain (i.e. admin.site.com, community.site.com, www.site.com) but each of the subsections will be pulling from the same database so should be sharing the same models. Is there a way to organize it so that I can use the same Kohana model/system/module files for each of the subdomains, but keep the application folder separate? Something like:

/home/user/admin/
    application/
        bootstrap.php
        cache/
        ...
    index.php

/home/user/community/
    application/
        bootstrap.php
        cache/
        ...
    index.php

/home/user/public_html/
    application/
        bootstrap.php
        cache/
        ...
    index.php

/home/user/kohana/
    modules/
        ...
        models/
        ...
    system/

That way I can keep Kohana up-to-date across three sites with only one update, plus I can use the same modules and model classes. Is there any way I can make this happen? Or is there some other method I should be using?

Thanks!

+2  A: 

I figured out how to do this, so I thought I would answer it in case someone else needs to know.

I moved my system and modules folders out of the webroot (to /home/user/kohana/) and created a folder there called sites. Then I created three separate folders in /home/user/kohana/sites/ for each of my three subdomains (admin, community, and www). I copied the contents of the application folder to each of these folders, then copied the index.php and .htaccess files to the webroots for each subdomain.

In each of the index.php files, at the top, I added:

$install_dir = '../kohana/';

and edited the following directory variables to include the new path:

...
$application = $install_dir.'sites/admin';
...
$modules = $install_dir.'modules';
...
$system = $install_dir.'system';

And it worked! I feel kind of stupid for not realizing how easy it was to move the directories around. Hopefully my explanation is coherent and assists someone else in the future.

ceolwulf
You can move the application folder outside the web root as well and just have public static assets like Javascript, images and stylesheets in the web root. All you need to keep in web root is index.php.
GC