【发布时间】:2014-10-29 17:34:26
【问题描述】:
我刚开始使用 Zend 框架,我不太确定我在 URI 路由上做错了什么。
我从 Zend Studio 中的一个初始 Zend Framework 项目开始,该项目位于我的 htdocs 文件夹中(我也在 Windows 7 上使用 Zend Server)。到那里的一切似乎都可以正常运行索引页面(它已经用完了 /public/ 子目录)。
但是,当我尝试添加一个模块时,在这种情况下称为用户,并带有一个名为 Index 的控制器,并按照配置的说明进行操作,我不确定应该在 URI 中放入什么来获取它通往它的视野。我已经尝试了几乎所有我能想到的 URI 组合配置(localhost:80/public/users、localhost:80/public/users/index、localhost:80/users 等)
我没有收到路由错误,只是一个普通的 404 页面。
我需要将公用文件夹设置为根目录吗?或者我还需要做些什么才能让路由正常工作?
~响应bitWorking编辑
看起来它确实会自动将其添加到 application.config.php。但是这里是Users模块的module.config.php
'router' => array(
'routes' => array(
'users' => array(
'type' => 'Literal',
'options' => array(
// Change this to something specific to your module
'route' => '/index',
'defaults' => array(
// Change this value to reflect the namespace in which
// the controllers for your module are found
'__NAMESPACE__' => 'Users\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
// This route is a sane default when developing a module;
// as you solidify the routes for your module, however,
// you may want to remove it and replace it with more
// specific routes.
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
现在我确实看到了它引导您自定义路线的位置。我也尝试过这个,但仍然不确定我应该将它们设置为什么。不过更近了。
【问题讨论】:
-
您已将该模块添加到
application.config.php?否则请从module.config.php..发布路线。
标签: php zend-framework zend-framework2 zend-studio zend-server