0

Some body please help me how to get full url i.e with scheme and host of the current page in the view. I tried the following, but didnt return the expected results

$this->request->here; // returns uri plus base path. no host & scheme
$this->request->here(true); // same problem

2 Answers2

2

You can get domain,scheme,path like this :

use Cake\Routing\Router;
$domain = parse_url(Router::url('/', true));
pr($domain);

OR

use Cake\Routing\Router;
$url = Router::url(null, true);

Controller,action path can be get by :

$this->request->here
Akshay Sharma
  • 1,042
  • 1
  • 8
  • 21
2
<?= $this->Url->build(null, true); ?>

Here you are more info:

http://book.cakephp.org/3.0/en/views/helpers/url.html#generating-urls

Jacek B Budzynski
  • 1,393
  • 1
  • 7
  • 13