How to Get Current URL in Laravel?

25-Jul-2022

.

Admin

How to Get Current URL in Laravel?

This tutorial shows you laravel get current url in controller. I would like to share with you laravel get current url in view. This post will give you simple example of get current url in laravel . it's simple example of laravel get current url. Here, Creating a basic example of get current page url in laravel.

Here is few examples you may use to get current route and url data. The methods will automatically use the schemes(http or https) from url.

Get Current URL in Laravel:


Example 1: current() with Helper

$currentURL = url()->current();

dd($currentURL);

Example 2: full() with Helper(with query string parameters)

$currentURL = url()->full();

dd($currentURL);

Example 3: current() with Facade

$currentURL = URL::current();

dd($currentURL);

Example 4: full() with Facade(with query string parameters)

$currentURL = URL::full();

dd($currentURL);

Example 5: using Request

$currentURL = Request::url();

dd($currentURL);

It will help you...

#Laravel 9

#Laravel 8

#Laravel 7

#Laravel