3

In phalcon 3.4 we had the below function to get the current URL,

$current_url = $this->router->getRewriteUri();

However, it seems to be that, it was dropped in version 4.0 however there is no direct corresponding function for this i could find. Can you please let me know how to change this function to adapt to version 4.0+ Or should i just use the direct way (I usually hate to mix things up) but looks like no other choice

$_SERVER['REQUEST_URI']
mahen3d
  • 7,047
  • 13
  • 51
  • 103

2 Answers2

3

you can use Phalcon\Http\Request::getURI() but it uses $_SERVER['REQUEST_URI'] if your project is not on root path you may want to use $_GET['_url']

Talal
  • 394
  • 1
  • 13
0

You can use the $this->request->getURI() to obtain it as string (same as $_SERVER['REQUEST_URI']), like:

/mycontroller/action?someparam=value

... or the $this->request->getQuery() if you want to get it parsed, like:

array(2) {
  ["_url"]=>
  string(13) "/mycontroller/action"
  ["someparam"]=>
  string(2) "value"
}
Vasil Popov
  • 1,210
  • 14
  • 22