How to Get Path in Laravel Application Root?

By Hardik Savani November 5, 2023 Category : Laravel

Hello Artisan,

Now, let's see a tutorial of how to get path in laravel. This article goes in detailed on how to get public path in laravel. let’s discuss about how to get base path in laravel. I would like to show you how to get storage folder path in laravel. Alright, let’s dive into the details.

Laravel provide several helper to get path of public directory, app directory, storage directory and base directory. It will help to store files, read file from path and also for other from controller, view files, model etc.

You can see as bellow how to get path of that directory using helper one by one.


How to Get Public Folder Path in Laravel?

public_path(); // /var/www/example-app/public


How to Get Base Path(Project Root) in Laravel?

base_path(); // /var/www/example-app


How to Get Storage Folder Path in Laravel?

storage_path(); // /var/www/example-app/storage


How to Get App Folder Path in Laravel?

app_path(); // /var/www/example-app/app

I hope it can help you...

Tags :
Shares