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