Laravel 7.x and 6.x Get Site URL Examples

August 2, 2017 | Category : Laravel PHP

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...