在我模塊的module.config.php
,我有這樣的事情:ZF3:如何根據方法和路線路由到特定控制器/操作?
namespace Application;
return [
//...
// myroute1 will route to IndexController fooAction if the route is matching '/index/foo' but regardless of request method
'myroute1' => [
'type' => Zend\Router\Http\Literal::class,
'options' => [
'route' => '/index/foo',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'foo',
],
],
],
// myroute2 will route to IndexController fooAction if the route is request method is GET but regardless of requested route
'myroute2' => [
'type' => Zend\Router\Http\Method::class,
'options' => [
'verb' => 'get',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'foo',
],
],
],
//...
];
我想要實現:
- 如果路線/索引/富請求,並通過要求GET方法,那麼它應該被路由到IndexControllerfooAction
- 如果r歐特/索引/富請求,並通過POST法的要求,那麼它應該被路由到的IndexController酒吧行動(注意到它的barAction這裏沒有fooAction)
如何實現那?
那我正在尋找的東西。但我注意到它提到「'部分'路線不是直接使用」。 – evilReiko