我试图构建一个控制器,其功能是获得一个“外部”控制器。 URL并将其转换为内部URL。外部网址如下所示:http://localhost/dir/public/api?entity=11
,内部网址如下:http://localhost/dir/public/en/entity/1254
。我的module.conf.php是这样的:
'router' => array(
'routes' => array(
'api' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/api',
'defaults' => array(
'__NAMESPACE__' => 'Extranet\Controller',
'controller' => 'api',
'action' => 'index',
),
),
),
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '[/:locale]',
'constraints' => array(
'locale' => 'ca|es|en',
),
'defaults' => array(
'__NAMESPACE__' => 'Extranet\Controller',
'controller' => 'Entity',
'action' => 'index',
'locale' => 'ca',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/:controller[/:id]]',
'constraints' => array(
'controller' => '(?!intranet)(?!api)([a-zA-Z][a-zA-Z0-9_-]+)',
'id' => '[a-z0-9]+',
),
),
'defaults' => array(
'__NAMESPACE__' => 'Extranet\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
),
),
),
),
问题是,当我在我的控制器上写:$this->params()->fromQuery();
这个参数是空的,我不明白为什么,因为如果我在我的代码中写了一些var_dump(),它就可以了!我绝望了。
由于