这是我要路由我的应用程序的路由转储。
[album] => Array([route] => Zend\Mvc\Router\Http\Segment Object
(
[parts:protected] => Array
(
[0] => Array
(
[0] => literal
[1] => /album
)
[1] => Array
(
[0] => optional
[1] => Array
(
[0] => Array
(
[0] => literal
[1] => /
)
[1] => Array
(
[0] => parameter
[1] => action
[2] =>
)
)
)
[2] => Array
(
[0] => optional
[1] => Array
(
[0] => Array
(
[0] => literal
[1] => /
)
[1] => Array
(
[0] => parameter
[1] => id
[2] =>
)
)
)
)
[regex:protected] => /album(?:/(?P[a-zA-Z][a-zA-Z0-9_-]*))?(?:/(?P[0-9]+))?
[paramMap:protected] => Array
(
[param1] => action
[param2] => id
)
[defaults:protected] => Array
(
[controller] => Album\Controller\Album
[action] => index
)
[assembledParams:protected] => Array
(
)
)
[priority] => 0
[serial] => 3
)
但是当我尝试这个时
$router = $e->getRouter();
$url = $router->assemble(array(), array('name' => 'Album\index'));
我收到以下错误。
找不到名称为“专辑\索引”的路线
Edit: here is route settings from module.config
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
编辑:据建议,我做了以下更改
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album',
'constraints' => array(
'action' => 'index',
// 'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'process' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:action]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
但现在我似乎无法通过索引操作。我的意思是对我可见的专辑模块的唯一操作是索引,没有其他人可以纠正/建议必须做什么?