I'm looking to set up a Kohana 2.3.4 site, and would like to have a shared set of models/config/libraries/helpers, with both the front-end and the admin panel having their own controllers/views.
What would be the best way to set up the file system to create something like this?
Cheers.
Quick update:
I've got it working in a hackyish way by setting up:
/
application/
- config/
- controllers/
- views/
application_admin/
- config/
- controllers/
- views/
modules/
- shared_code/
- - models/
www_root/
- admin/
- - index.php
- index.php
Then the admin/index.php points at ../../application_admin, the public index.php points to ../application, and in config/config.php for both the admin and public, I've enabled the "shared_code" module.
Is there a better way, or any improvements to doing it like this?
it solely depends on how you arranged the admin-site. For example, is it a separate module, or just a "namespaced controller" (controllers/admin/home.php
=> class Controller_Admin_Home {}
). But as kohana uses the cascaded file system, you can use any class in any place. Assume you have a module Sandbox
in modules/sandbox/
, with the model sand
, located in modules/sandbox/models/sand
, you could call $sand_model = new Sand_Model
from anywhere
--- note; this works in kohana 3.x at least, i'm not certain if this applies to the 2.x branch too. But I think you should use 3.x anyway as it's more stable, flexible and has more features you'd definitley want