php - Laravel: Get base url -


simple question, answer seems quite hard come by. in codeigniter, load url helper , do

echo base_url(); 

to site's url. there equivalent in laravel?

you can use url facade lets calls url generator

so can do:

url::to('/'); 

you can use application container:

$app->make('url')->to('/'); $app['url']->to('/'); app::make('url')->to('/'); 

or inject urlgenerator:

<?php namespace vendor\your\class\namespace;  use illuminate\routing\urlgenerator;  class classname {     protected $url;      public function __construct(urlgenerator $url)     {         $this->url = $url;     }      public function methodname()     {         $this->url->to('/');     } } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -