Laravel 5 Get Site URL Examples


In this article i will let you know how to get homepage or site url in your controller, blade file, model etc. So as we know we may need to get base url of our website then we can get it several way in laravel 5 application.

Here, i will give you several examples of how to get base url in view file or controller etc. So you can use any as your requirement or work as you expect. So simply let's see bellow examples one by one.

Example 1:

Route::get('site-url', function () {

dd(\URL::to('/'));

});

Example 2:

Route::get('site-url', function () {

dd(url('/'));

});

Example 3:

Route::get('site-url', function () {

dd(asset('/'));

});

Example 4:

Route::get('site-url', function () {

dd(config('app.url'));

});

I hope you found your best...


August 2, 2017 | 109 Viewer | Category : PHP Laravel
Related Posts:



Blog Search