所以我有一个模块,名为用户,并在这个模块内部我有一些控制器,现在我有一个注销控制器,我想创建网址(domain.tld /用户/注销)在我看来这个控制器。我想是这样的:ZF2网址视图帮手没有定义的路由
$this->url("user",array("controller" => "logout")); //This doesn't work
我也试过这样:
$this->url("user/logout"); //This doesn't work since there isn't a child route defined for the user
所以我的问题是,是否有使用url视图助手没有在module.config.php
这里是我的module.config.php
return array(
'router' => array(
'routes' => array(
'register' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'User\Controller\Index',
'action' => 'index',
),
),
),
'user' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'__NAMESPACE__' => 'User\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'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(
),
),
),
Woaw,很棒的知识,真的很感激它,谢谢它的作品! – Uffo