D
D
Dmitry2014-09-25 11:47:58
Zend Framework
Dmitry, 2014-09-25 11:47:58

How to get the current URL as an array in ZF2?

How to get the current URL in Zend 2 (only the controller, action and parameters are of interest) as an array? Or at least only parameters, as a string. It is necessary in order to compose the URL in the paginator, taking into account the parameter of the current page.
For example, from the url www.site.com/controler/action/param. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roquie, 2014-09-28
@another_dream

$uri = Zend\Uri\UriFactory::factory('http://example.com:80/my/path?a=b&c=d#token');

$scheme = $uri->getPath();  // "/my/path"
$scheme = $uri->getQuery();  // "a=b&c=d"
$scheme = $uri->getQueryAsArray();
// array(
//  'a' => 'b',
//  'c' => 'd',
// )

$scheme = $uri->getFragment();  // "token"

RTFM framework.zend.com/manual/2.0/en/modules/zend.uri.html
controller and action
$controllerName =$this->params('controller');
$actionName = $this->params('action');

use google, bro :)
stackoverflow.com/questions/12179840/how-to-get-co...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question