Laravel 5.7 Get Current URL with Parameters

Hi Developer,

In this small post, i wanted to show you how you can get current url or base url with parameters in your controller file or blade view file of laravel 5.7 project. So laravel 5.7 provide several way to get current app path using fullUrl(), current(), url() and segment() of request object. You can easily get by request object.

Laravel 5.7 provide Request and URL facade for getting request data. So we can simply get those current url using Request and URL facade. we can also get full url means you can get query string of url too. So i give you one by one both example As listed bellow:

Get Current URL with Parameters:

$currentURL = \Request::fullUrl();


Get Current URL without Parameters:

$currentURL = \URL::current();



$currentURL = \Request::url();


Get Only Parameters:

//Example URL: www.domain.tld/post/list?page=2

$parameters = \Request::segment(3);


I hope you found your solutions....

September 25, 2018 | Category : PHPLaravelLaravel 5Laravel 5.7
Related Posts