大家好,我在 Phalcon 的多模块项目中使用以下结构
[modules]
[module1]
[controllers]
[models]
[views]
[module2]
[controllers]
[models]
[views]
[module-n]
[controllers]
[models]
[views]
我在 bootstrap index.php 文件中仅注册了模块 1 和模块 2。像这样:
$this->registerModules(array
(
'Module1' => array(
'className' => 'Modules\Module1\Module',
'path' => '../modules/module1/Module.php'
),
'Module2' => array(
'className' => 'Modules\Module2\Module',
'path' => '../modules/module2/Module.php'
)
));
现在,我的默认模块是 Module 1 。我如何使用模块n的控制器(该模块尚未注册)。有没有动态注册模块的方法?
基本上,您应该避免在另一个模块中使用一个模块控制器。这不是应用程序的正确行为方式;)这更多的是关于一般良好的编程和设计模式,而不是 phalcon 本身。例如,您可以使用http://en.wikipedia.org/wiki/Service-orientation_architecture http://en.wikipedia.org/wiki/Service-oriented_architecture
可以动态注册服务并在模块之间共享它们,如果您正在寻找 Phalcon 中的实现,您可以检查 Vegas CMF:http://vegas-cmf.github.io/1.0/guide/di/service-manager.html http://vegas-cmf.github.io/1.0/guide/di/service-manager.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)