How to Get Current Route Name in Laravel?

By Hardik Savani November 5, 2023 Category : Laravel

Hello Guys,

In this post, we will learn laravel get current route name. you will learn how to get current route name in laravel. you will learn how to get current url name in laravel. step by step explain laravel get current route. Here, Create a basic example of laravel get route name from url.

You can use this example with laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 versions.

If you need to get the current route name, you can use either the Request or Route facade. I will give you two examples, one for using the Route facade and another for using the Request facade, so you can get the route name using either method. You can see both examples below.

Using Request:

$routeName = Request::route()->getName();

print($routeName);

Using Route:

$routeName = Route::getCurrentRoute()->getPath();

print($routeName);

I hope it can help you...

Tags :
Shares