【发布时间】:2013-04-02 23:11:30
【问题描述】:
我一直在学习 Zend (http://www.youtube.com/watch?feature=player_embedded&v=EerB9bTvqrY) 的教程,但是当我在我的项目中添加一个新模块时,我无法导航到它,本教程中的说明是否不正确?
基本上,当我在 Zend Studio 中将一个新模块添加到我的 Zend Framework 项目时,我无法导航到它,我的新模块称为“交易”。我导航到 localhost/dealproject/deals 并收到错误 404。导航到 localhost/dealproject/ 时,它会正确加载 zend 框架应用程序页面。
感谢您的帮助。
module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Deals\Controller\Deals' => 'Deals\Controller\DealsController',
),
),
'router' => array(
'routes' => array(
'deals' => array(
'type' => 'Literal',
'options' => array(
// Change this to something specific to your module
'route' => '/deals',
'defaults' => array(
// Change this value to reflect the namespace in which
// the controllers for your module are found
'__NAMESPACE__' => 'Deals\Controller',
'controller' => 'Deals',
'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(
),
),
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'Deals' => __DIR__ . '/../view',
),
),
);
【问题讨论】:
-
能否请您从导致问题的模块的 module.config.php 中向我们展示您的路由配置:)
-
我现在已经在问题中发布了 module.config.php。感谢您的帮助。
-
谢谢,我觉得不错:)。我在答案中发布了一些内容,希望它可以帮助您解决 404 :)
标签: php zend-framework2 zend-studio