ItSolutionStuff.com

How to Get Current Full URL in Laravel 9?

By Hardik Savani • November 5, 2023
Laravel

Today, I would like to show you laravel 9 get current url in controller. This post will give you simple example of laravel 9 get current url in view. you will learn get current url in laravel 9. step by step explain laravel 9 get current url.

Laravel provide URL facade that way we can get current URL anywhere, as bellow you can see i use current() of URL facade. URL facade through you can get your current page url from every where. So you can check your current url this way:

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);

Get Previous URL in Laravel:

$url = url()->previous();

dd($url);

Get Current Route in Laravel:

$route = Route::current()->getName();

dd($route);

I hope it can help you....

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel 9 Create Multi Language Website Tutorial

Read Now →

How to Merge Multiple PDF Files in Laravel 9?

Read Now →

Laravel 9 User Roles and Permissions Tutorial

Read Now →

How to Create Custom Error Page in Laravel 9?

Read Now →

Laravel 9 QR Code Generator Example

Read Now →

Laravel 9 Multiple Database Connections Example

Read Now →

Laravel 9 Socialite Login with Twitter Account Example

Read Now →

Laravel 9 Model Observers Example Tutorial

Read Now →

Laravel 9 Socialite Login with Google Account Example

Read Now →

Laravel 9 Resize Image Before Upload Example

Read Now →

Laravel 9 Multi Auth: Create Multiple Authentication in Laravel

Read Now →

Laravel 9 REST API with Passport Authentication Tutorial

Read Now →