Kohana autoload Sub-Model

419 Views Asked by At

First of all, i'm using Kohana 2.3.4.

My question is, as Kohana docs says, Models must be in application/Models but to improve my app, I would like to have several sub-folders with other Models. This is useful because I can have a file tree more organized.

So, if I try to load a Model in a subfolder, 'class not found' error is returned, and if I move that class to main Model folder it works correctly.

So, my question is, how can i load the models in these subfolders?

1

There are 1 best solutions below

4
On

IIRC, models are only auto-loaded from the base models/ path in kohana 2. You'd have to include the file by hand if you had it somewhere else:

require Kohana::find_file('models', 'path/to/model')

I think that's the right syntax. If it's not, just take a look at the kohana class.