Cakephp 3.0 | Methods to get base and application url

Author - Parminder Kaur
24.05.2017
|
0 Comments
|

In cakephp we do not need to set hard coded relative paths.There are methods by calling which we can build the url dynamically.

use Cake\Routing\Router;
To get the base url use
Router::fullBaseUrl(); => http://localhost //Output

To get the Application Url
Router::url(); =>/CakeApp/ //Output

To build complete URL of controller and method called:
$this->Url->build([‘controller’=>Users,’action’=>’index’])

//output is
/users/index

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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