php - ZF3: How to route to specific controller/action based on method and route? -


in module's module.config.php, have this:

namespace application;  return [     //...     // myroute1 route indexcontroller fooaction if route matching '/index/foo' regardless of request method     'myroute1' => [         'type' => zend\router\http\literal::class,         'options' => [             'route'    => '/index/foo',             'defaults' => [                 'controller' => controller\indexcontroller::class,                 'action'     => 'foo',             ],         ],     ],      // myroute2 route indexcontroller fooaction if route request method regardless of requested route     'myroute2' => [         'type'    => zend\router\http\method::class,         'options' => [             'verb'     => 'get',             'defaults' => [                 'controller'    => controller\indexcontroller::class,                 'action'        => 'foo',             ],         ],     ],     //... ]; 

what i'm trying achieve:

  • if route /index/foo requested , requested get method, should routed indexcontroller fooaction
  • if route /index/foo requested , requested post method, should routed indexcontroller baraction (notice it's baraction here not fooaction)

how achieve that?

try changing literal zend\mvc\router\http\part route, , putting http routes in child routes!

see here https://docs.zendframework.com/zend-router/routing/#http-route-types


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -