ZF2:在控制器中获取 url 参数
2022-08-30 16:12:52
我经历过Zend Framework 1,并且我已经使用该框架构建了一些应用程序。
现在,我正在试验Zend Framework 2,但我卡在url参数上。我是这样设置路由的:
// Setup for router and routes
'Zend\Mvc\Router\RouteStack' => array(
'parameters' => array(
'routes' => array(
'default' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/[:slug]',
'constraints' => array(
'slug' => '[a-zA-Z][a-zA-Z0-9_\/-]*'
),
'defaults' => array(
'controller' => 'Htmlsite\Controller\BootController',
'action' => 'index',
'slug' => 'home'
),
),
),
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Htmlsite\Controller\BootController',
'action' => 'index',
),
),
),
),
),
),
正如你所看到的,我试图制作一个可变的slug。如何访问此变量?