Today, We want to share with you laravel base url.In this post we will show you get base path in laravel, hear for get base url or home page url of your laravel application we will give you demo and example for implement.In this post, we will learn about get base path in laravel with an example.
Laravel Get Base URL in Controller
Contents
How to Get Site URL in Laravel?
$url = URL::to("/"); print_r($url); $url2 = url('/'); print_r($url2);
Example 1:
Here url method to getBaseURL in controller
public function getBaseURL() { $url = url()->full(); print_r($url); }
Example 2:
Now in this example in request facade of url method using getBaseURL in laravel controller
public function getBaseURL() { $url = \Request::url(); print_r($url); }
Example 3:
Here in this example in request facade of fullUrl method using getBaseURL in laravel controller
public function getBaseURL() { $url = \Request::fullUrl(); print_r($url); }
Example 4:
Now In this example in url facade of current method using getBaseURL in laravel controller
public function getBaseURL() { $url = \URL::current(); print_r($url); }
I hope you get an idea about laravel url helper.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donβt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.