How to Get Root Path in Laravel Application?

Jul 03, 2024 | Laravel 10 Laravel 11 Laravel


Hello Dev,

In laravel, you have got helpers that make it clean to find out important listing paths like public, app, garage, and the lowest listing. These helpers are vital for obligations which includes record garage, gaining access to particular files, and similarly, across unique parts of your software like controllers, perspectives, and models.

Here’s how you may use those helpers to get the paths you need:

1. Public listing route:

laravel gives you a characteristic to find out your public list. ⁤⁤this folder normally houses your public-coping with stuff like css, javascript, and pics. ⁤

2. App listing route:

every different helper function offers you the direction to the app listing. This listing carries your software program software's middle documents and folders, inclusive of controllers, models, and services.

3. Storage directory course:

laravel additionally provides a helper function mainly for the storage list. This list is vital for storing documents that are not immediately on hand to the general public, which include individual uploads or cached statistics.

4. Base directory route:

eventually, there may be a helper feature to fetch the lowest listing path of your laravel utility. This is the region to start for locating fantastic directories and files internal your software program shape.

Those helper features simplify management tasks, making it easy to navigate and manipulate files from various elements of your laravel software program, no longer having to manually gather paths on every time.

Read Also: How to Disable a Anchor Tag in Using HTML? How to Get Public Folder Path in Laravel?
public_path(); // /var/www/example-app/public
Read Also: How to Show Image from Storage Folder in Laravel? How to Get Base Path(Project Root) in Laravel?
base_path(); // /var/www/example-app
Read Also: Laravel 11 Create Comment System with Replies Example How to Get Storage Folder Path in Laravel?
storage_path(); // /var/www/example-app/storage
Read Also: Laravel 11 Database Notifications Example Tutorial How to Get App Folder Path in Laravel?
app_path(); // /var/www/example-app/app

Feel free to ask if you have any questions or need further clarification!



Tags :
#Laravel 10
#Laravel 11
#Laravel
ItErrorSolution.com

ItErrorSolution.com

"Hey there! I'm a full-stack developer and proud owner of ItErrorSolution.com, based right here in India. I love nothing more than sharing handy tips and tricks with my fellow developers through easy-to-follow tutorials. When it comes to coding, I'm all about PHP, Laravel, Angular, Vue, Node, JavaScript, jQuery, CodeIgniter, and Bootstrap – been hooked on them forever! I'm all about putting in the work and staying committed. Ready to join me on this journey to coding?"