Spread the love

Laravel has a lot of features and packages available for file system, database, model, view etc.

Laravel has helpers to get the path of root folder, public folder, assets folder, storage folder, app folder.

To get the path of app folder we can use app_path() function in laravel which gives the path of app folder in laravel project.

app_path();
//we can pass parameters to app_path function

app_path("Http/Controllers");

Output will be:

var/www/html/app/Http/Controllers

To get the path of storage folder in laravel we can user storage_path() function which gives path of storage folder.

storage_path();
//we can pass parameters to storage_path() function

storage_path("app");

Output will be:

var/www/html/storage/app

To get the path of root folder in laravel we can user base_path() function which gives path of root folder.

base_path();
//we can pass parameters to base_path() function

base_path("app");

Output will be:

var/www/html/app

To get the path of public folder in laravel we can user public_path() function which gives path of public folder.

public_path();
//we can pass parameters to public_path() function

public_path("images");

Output will be:

var/www/html/public/images

To get the path of resource folder in laravel we can user resource_path() function which gives path of resource folder.

resource_path();
//we can pass parameters to resource_path() function

resource_path("layout");

Output will be:

var/www/html/resource/layout

To get the path of config folder in laravel we can user config_path() function which gives path of config folder.

config_path();
//we can pass parameters to resource_path() function

config_path("config.php");

Output will be:

var/www/html/config/config.php

Leave a Reply