July 17, 2014 | In: Programovanie
zend framework 2 – how to get params
how to get params out of the request
http://domain.ltd/controller/get/5?id=5
/apigility/resource[/:id]?lang=en_US
// module.config.php
// 'route' => '/[:controller[/:action[/:id]]]',
// apigility module.config.php
// key zf-rest
// 'collection_query_whitelist' => array('lang'),
var_dump(
$this->getEvent()->getQueryParams(),
$this->getEvent()->getParams(),
$this->getEvent()->getRouteParam('id),
$this->getEvent()->getRouteMatch()->getParam('id'),
// controller: (which goes like (new HttpRequest)->method(Params() param)...
$this->params()->fromRoute('id'),
$this->params()->fromQuery('id'),
$this->params()->fromPost('id'),
$this->params('id')
);
Comments are closed.