| Viewed 18 times

How to get the path to the project root directory in laravel


How to get the path to the project root directory in laravel

1 Answer
Mohammad Qandeel
Answered
0

You can use the base_path() helper function to get the path to the root directory in laravel

For Laravel developers, think of the root directory like a base path for your project.

The Root Directory have these folders

  1. The app Directory
  2. The bootstrap Directory
  3. The config Directory
  4. The database Directory
  5. The public Directory
  6. The resources Directory
  7. The routes Directory
  8. The storage Directory
  9. The tests Directory
  10. The vendor Directory

If you want to get the path to the project root directory in laravel you can use the base_path() helper function which will return a string

Example of how to use base_path() helper function

$path = base_path();

Output (output difference based on your project)

"C:\xampp\htdocs\laravel\shop"



Related FAQ