How to Get Site URL in Laravel?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in post i would like to share you how to get site url in laravel. Now here is a quick post, which can help you to get the base url or home page url of your laravel application. So I think many of times we need to get the site URL for the something share or link. so we can get that by using the url helper and URL facade. Both of way are same we can use that anywhere i mean in controller or view.

So let’s start and see the example.

Example:
$url = URL::to("/");
print_r($url);

$url2 = url('/');
print_r($url2);

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →