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

Module Facade

Hi

I want have access to model in another module without registering namespace in current module. beacuse i use diffrent config in that module. i need sth similar to zend module facade



12.2k

Can't you register a service? Something like:

$di->setShared('myModuleName', function() {
   $model = new MyModel;
    return $model;
});

And then access it wherever:


$model = $this->getDi()->get('myModuleName');

I'm afraid you can't do that, since there must be an autoloading strategy for the engine to find the actual model class.

You can use Phalcon\Mvc\Model\Manager:registerNamespaceAlias() to assign a custom prefix for different model namespaces

Just register ALL MODELS in loader outside of modules. Like before registering modules for example. @mraspor solution is really bad, also it's not really a solution.



11.0k

register your module with phalcon namespace i've used it , very awesome :) https://docs.phalcon.io/en/latest/reference/namespaces.html