Getting baseurl in any framework is easy. But development URL in cakephp 3 in view file…took time…For adding css or js or other purpose we need base path cakephp.
While doing development my path was http://localhost/cakephp3/. I wanted to fetch that in my site.
Their are many ways we can get the path.
You can use any one method of following :
<?php echo $this->Html->url('/', true) echo $this->Html->url('/'); ?>
Define constant in Config/core.php as given bellow:
define(“BASE_URL”, “localhost/cakephp3/”);
Then you can use BASE_URL in view file.
For view file you can use following code.
<?php echo $this->Url->build('/', true); ?>
I used above code reference to following URL:
http://book.cakephp.org/3.0/en/views/helpers/url.html#generating-urls