We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.



47.7k
edited Sep '15

https://docs.phalcon.io/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/',
            )
        );


34.6k
Accepted
answer

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