Get base url or development URL in cakephp 3 and use in view ctp file

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 :

    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:


Add a Comment

Your email address will not be published. Required fields are marked *