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



6.5k

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.



8.1k

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