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.

Multiple Modules - Shared Model?

I have seen how you can share common layouts in two different modules views.

How can I share the same model directory. Or is the point that seperating modules forces you into seperating your models?

Is it valid to want to have two seperate modules when you only to seperate controllers and views.



19.6k
edited Sep '15

https://docs.phalconphp.com/en/latest/reference/applications.html

In Backend\Module.php set the models namespace to the common directory:

$loader->registerNamespaces(
            array(
                'Multiple\Backend\Controllers' => '../apps/backend/controllers/',
                'Multiple\Backend\Models'      => '../apps/common/models/',
            )
        );


33.4k
Accepted
answer

There are many examples in the MVC sample that can help you: https://github.com/phalcon/mvc#phalcon-mvc-examples



40.5k

Check out my Webird framework. I'm doing basically all of the things in the example plus some other ideas. There are shared models, shared layout and partial views between modules and each module can have its own private layouts and partials. I accomplished having both a shared view and private module view capability by adding a few Volt extensions. Additionally the build process compiles the views for the production release.