我已经使用 Skeleton Application and Module 创建了一个基本的 Zend Framework 2 应用程序,尽管我遇到了路由问题并且似乎无法解决它。
在我的模块中,它松散地基于 Zend Framework 网站上的新快速入门模块,我在 module.config.php 中有以下路由
'router' => array(
'routes' => array(
'blog' => array(
'type' => 'Literal',
'options' => array(
// Change this to something specific to your module
'route' => '/blog',
'defaults' => array(
// Change this value to reflect the namespace in which
// the controllers for your module are found
'__NAMESPACE__' => 'Blog\Controller',
'controller' => 'View',
'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(
),
),
),
),
),
),
),
使用标准模块、控制器和操作 URL 请求时,此路由似乎可以正常工作:
blah.com/blog/post/view
我遇到问题的地方是当我尝试通过 URL 传递一些数据时:
blah.com/blog/post/view/id/1
两个 URL 中的后者导致 404。我猜我需要一个子路由来允许在 URL 上传递数据,尽管我完全坚持我所需要的。有人能指出我正确的方向吗?我已经浏览了参考指南,尽管我似乎无法越界。
任何帮助表示赞赏。