所以我有一個模塊,名爲用戶,並在這個模塊內部我有一些控制器,現在我有一個註銷控制器,我想創建網址(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