Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Models in other Module

Hello, How can i use a model in other module ?

edited Oct '14

That depends I have a multi module setup with a Core module where the models are all in. In the module config files I point to that folder for the models. But this means all models are in one place.

modelsDir = ../apps/core/models/

Inside the Module bootstrapper I register the models namespace.

class Module implements ModuleDefinitionInterface

     * Registers the module auto-loader
    public function registerAutoloaders()

        $loader = new Loader();

            'Shinzou\Account\Controllers' => __DIR__ . '/controllers/',
            'Shinzou\Core\Models' => __DIR__ . '/../core/models/',
            'Shinzou\Core\Controllers' => __DIR__ . '/../core/controllers/',
            'Shinzou\Account\Forms' => __DIR__. '/forms',
            'Shinzou\Core\Library\Mail' => __DIR__ . '/../core/library/Mail/',


Hope this helps...




Smal note. If you read about PSR-0, you can make your code shorter :)

$app_root = ''; // directory root of you namespace
            'Shinzou' => $app_root