It is pretty easy to get the current Url Path in Laravel 8. Just follow these steps
Step 1: Set up a new Laravel project by running the following command on the composer
composer create-project --prefer-dist laravel/laravel url_path
Laravel files will be generated in a new folder, "url_path."
Step 2: Our laravel project has been created. Go to http://127.0.0.1:8000 in your browser to see this page:
Step 3: To display our current URL path, we need to do this. Add the following code to your welcome.blade.php file:
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
<!-- Styles -->
font-family: 'Nunito', sans-serif;
// this line gets the Current Filename.
// this line gets the directory name where file have been stored
$currentPage = substr($currentPage, 1);
// this line displays the current Filename
Step 4: To see your URL path, go to http://127.0.0.1:8000 in your web browser
That’s it, our URL path is displayed on our screen.
Article Contributed By :