How to get complete current url for Cakephp

I prefer this, because if I don't mention "request" word, my IDE gives warning.

<?php echo $this->request->here; ?>

API Document: class-CakeRequest


Edit: To clarify all options

Current URL: http://example.com/en/controller/action/?query=12

// Router::url(null, true)
http://example.com/en/controller/action/

// Router::url(null, false)
/en/controller/action/

// $this->request->here
/en/controller/action/

// $this->request->here()
/en/controller/action/?query=12

// $this->request->here(false)
/en/controller/action/?query=12

// $this->request->url
en/controller/action

// $_SERVER["REQUEST_URI"]
/en/controller/action/?query=12

// strtok($_SERVER["REQUEST_URI"],'?');
/en/controller/action/

You can do either

From a view file:

<?php echo $this->request->here() ?>">

Which will give you the absolute url from the hostname i.e. /controller/action/params

Or

<?php echo Router::url(null, true) ?> 

which should give you the full url with the hostname.


<?php echo $_SERVER[ 'REQUEST_URI' ]; ?>

EDIT: or,

<?php echo $this->Html->url( null, true ); ?>

Tags:

Php

Cakephp