How to get Main or Base URL in Laravel?

Today, We want to share with you base url in laravel.In this post we will show you laravel get current url, hear for app_url laravel we will give you demo and example for implement.In this post, we will learn about get current path in laravel with an example.

5 Ways To Get Base UR in Laravel

Laravel Get Base Url : You Can the get current url in laravel as below.

Read Also:  PHP Laravel MySQL CRUD Application

Laravel Get Base Url Syntax

 $baseurl = url();

get app url in laravel

URL::to('/');

Laravel Get Base URL in Controller

Example 1:

/**
* Show the application Homepage.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
    $url  = url()->full();
    dd($url);
}

Example 2:

**
* Show the application Homepage.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
    $url  = \Request::url();
    dd($url);
}

Example 3:

/**
* Show the application Homepage.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
    $url  = \Request::fullUrl();
    dd($url);
}

Example 4:

/**
* Show the application Homepage.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
    $url  = \URL::current();
    dd($url);
}

I hope you get an idea about how to know Current url in laravel?.
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.