CakePHP3: Get the full URL of the current page

Method 1: Use the URL helper


$url = $this->Url->build([
"controller" => "Posts",
"action" => "search",
"?" => ["foo" => "bar"]
],true);


Method 2: Use the Router


use Cake\Routing\Router;

$url = Router::url([
'controller' => 'Posts',
'action' => 'search',
'?' => ['foo' => $bar]
], true);
#cakephp3

People Who Wowed This Post

×
  • If you are a bloguru member, please login.
    Login
  • If you are not a bloguru member, you may request a free account here:
    Request Account