我读过一本名为《zend framework: beginner's guide》的书。有人提到,创建模块和对事物进行分类是最佳做法。
我已将模块目录添加到应用程序目录中,并将视图,控制器和模型目录移动到其中。结构如下:
应用
- 配置
- 模块
- 引导.php
当我弹出打开浏览器并浏览到以下 URL 时:
localhost/square/default/index/index
或
localhost/square/public/default/index/index
我收到not found
错误消息。我更改了配置文件(应用程序.ini),如下所示:
resources.frontcontroller.controllerDirectory = APPLICATION_PATH "/modules/default/controllers"
resources.frontcontroller.params.displayExceptions = 0
resources.frontcontroller.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""
我已经阅读了以下问题,但这没有帮助:
更改 Zend 框架默认模块
Zend 框架不包含 url 中的默认模块
只需使用这个:
resources.frontcontroller.controllerDirectory = APPLICATION_PATH "/controllers"
编辑:
我注意到您使用localhost/square/来访问您的页面。您必须设置虚拟主机来解决问题,因为路由器需要它才能正常工作。
请参阅:http://framework.zend.com/manual/1.12/en/learning.quickstart.create-project.html#learning.quickstart.create-project.vhost
这
应该有效。
resources.modules[] = ""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.defaultModule = "default"
resources.frontController.defaultControllerName = "index"
resources.frontController.defaultAction = "index"
resources.frontController.env = APPLICATION_ENV