php - How to setup zend 2 routing to expect certain get variables to be passed? -


my app expected handle url sent 3rd party app variables ie: 'www.example.com/user/login?idusuario=500'. configured route way:

'usuario' => array(             'type' => 'segment',             'options' => array(                 'route' => '/usuario[/:login][?:idusuario]',                 'constraints' => array(                     'login' => '[a-za-z][a-za-z0-9_-]*',                     'idusuario' => '[a-za-z][a-za-z0-9_-]*'                 ),                 'defaults' => array(                     'controller' => 'administrativo\controller\usuario',                     'action' => 'index'                 )             ),         ), 

now, problem app not 'seeing' variables passed through url. when try go params using: $this->getevent()->getroutematch()->getparams(); string like: array(3) { ["controller"]=> string(33) "administrativo\controller \usuario" ["action"]=> string(5) "index" ["login"]=> string(5) "login" }

it not recognizing variable idusuario. how can around this?

you need remove [?:idusuario] , corresponding constraint route. zf2 doesn't handle query parameters in routes. used to, it's since been deprecated.

instead, in controller need call $this->params()->fromquery() return array of query parameters appended onto url.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -