In this tutorial you will learn about the How to Get Site URL In Laravel and its application with practical example.
How to Get Site URL In Laravel
In this article, I’ll show you how to get site url in your laravel controller, blade file, model etc. Many times in laravel application development we need to get base url of our laravel application. There follwoing ways we can get site url in our laravel 5 application. In laravel 5 we can get site url or base url using url helper and url facade.
Get Site url Using URL Helper
Syntax:-
1 |
url('/') |
Example :-
1 |
echo url('/'); |
or
1 |
{{ url('/') }} |
Get Site url Using URL Facade
Syntax:-
1 |
URL::to("/") |
Example:-
1 2 |
$url = URL::to("/"); print_r($url); |