【发布时间】:2014-01-29 19:31:55
【问题描述】:
所以我有一个名为 User 的模块,在这个模块中我有一些控制器,现在我有一个注销控制器,我想在我的视图中为这个控制器创建 url(domain.tld/user/logout)。我试过这样:
$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 查看帮助程序定义 url 而无需在 module.config.php 中定义路由
这是我的module.config.phpsn-p
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(
),
),
),
【问题讨论】:
标签: php zend-framework zend-framework2