ItSolutionStuff.com

How to Get Current Full URL in Laravel 10?

By Hardik Savani β€’ November 5, 2023
Laravel

Hey Dev,

Today, laravel 10 get current url in controller is our main topic. I explained simply about laravel 10 get current url in view. In this article, we will implement a get current url in laravel 10. you can see laravel 10 get current url. Alright, let’s dive into the steps.

Laravel provides a URL facade that way we can get the current URL anywhere, as bellow you can see I use the current() URL facade. URL facade through which 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 10 Socialite Login with Google Account Example

Read Now β†’
β˜…

Laravel 10 Has Many Through Relationship Example

Read Now β†’
β˜…

Laravel 10 One to One Relationship Example

Read Now β†’
β˜…

How to Generate QR Code in Laravel 10?

Read Now β†’
β˜…

Laravel 10 Resize Image Before Upload Example

Read Now β†’
β˜…

Laravel 10 REST API with Passport Authentication Tutorial

Read Now β†’
β˜…

Laravel 10 Yajra Datatables Tutorial Example

Read Now β†’
β˜…

Laravel 10 Markdown | Laravel 10 Send Email using Markdown Mailables

Read Now β†’
β˜…

Laravel 10 Ajax Image Upload Example

Read Now β†’
β˜…

Laravel 10 Mail | Laravel 10 Send Mail Tutorial

Read Now β†’
β˜…

Laravel 10 Import Export Excel and CSV File Tutorial

Read Now β†’
β˜…

Laravel 10 Bootstrap Auth Scaffolding Tutorial

Read Now β†’
β˜…

Laravel 10 Generate PDF File using DomPDF Example

Read Now β†’
β˜…

Laravel 10 Multiple Image Upload Tutorial Example

Read Now β†’