How to get Laravel Application root path ?

Avatar
C

Callum Davies

Senior Backend Engineer••
8243Views
5mRead
0Reactions

I hope you're having a fantastic day! Today, I'm thrilled to share valuable insights on accessing critical paths such as the application root path and storage path in Laravel versions 5 through 9.

Laravel simplifies path management with a variety of handy helper functions designed to streamline tasks like retrieving the app path, public path, storage path, and base path. Let's dive into the methods for effortlessly accessing these essential paths:

How to get a public path

public_path()
//you can access public folder via this helper

How to get the Storage path

storage_path()
//you can access storage folder via this helper method.

How to get the App path

app_path()
//you can access app folder using this helper.

How to get the Base path

base_path()

//you can access root of the application using this helper. You can travel any of the folder using this folder.

Hope, it will help you.

Connect with KoderSolution 🚀

Master modern software engineering, scalable architectures, and advanced backend systems.

What's your setup?How does your production stack handle background jobs? Are you using Redis with Horizon, or cloud queues like AWS SQS?
Callum Davies
C
Written by•Senior Backend Engineer

Callum Davies

PHP & Laravel practitioner since v5.4. Big believer in thin controllers, explicit return types, and boring modular architecture that doesn't page you on weekends.

React to this article

Recommended Articles

View all articles