DEV Community

Cover image for How to Get Current Full URL in Laravel 11
Saddam Hossain
Saddam Hossain

Posted on

How to Get Current Full URL in Laravel 11

In this short article, I will show you how to get current full url in laravel 11 application. Laravel 11 provides several methods to get the current URL. You Can Learn Laravel 11 Generate and Read Sitemap XML File Tutorial
We will use the URL facade, url() helper, Route facade, and Request facade to get the current URL. So, let’s see one-by-one example below:

Lets Start How to Get Current Full URL in Laravel 11

Get Current URL in Laravel:

Example 1: current() with Helper

we can use current() function with url() helper to get current url:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function index(Request $request)
    {
        $currentURL = url()->current();

        dd($currentURL);
    }
}
Enter fullscreen mode Exit fullscreen mode

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

we can use full() function with url() helper to get current full url with query string parameters:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function index(Request $request)
    {
        $currentURL = url()->full();

        dd($currentURL);
    }
}
Enter fullscreen mode Exit fullscreen mode

Read More

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (0)

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more