Home >PHP Framework >Laravel >Summary of laravel common path saving (with code)

Summary of laravel common path saving (with code)

不言
不言forward
2019-03-26 10:56:332812browse

The content of this article is a summary of common path saving in laravel (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Common directory paths for laravel framework

app_path()

The app_path function returns the absolute path of the app directory:

$path = app_path();

You can also use the app_path function to generate an absolute path to a given file relative to the app directory:

$path = app_path('Http/Controllers/Controller.php');

base_path()

The base_path function returns the absolute path to the project root directory Path:

$path = base_path();

You can also use the base_path function to generate an absolute path to a given file relative to the application directory:

$path = base_path('vendor/bin');

config_path()

The config_path function returns the absolute path of the application configuration directory:

$path = config_path();

database_path()

database_path function returns the absolute path of the application database directory:

$path = database_path();

public_path ()

The public_path function returns the absolute path of the public directory:

$path = public_path();

storage_path()

The storage_path function returns the absolute path of the storage directory:

$path = storage_path();

You can also use the storage_path function to generate the absolute path of a given file relative to the storage directory:

$path = storage_path('app/file.txt');

The built-in helper functions for getting the path of the laravel project are basically here

This article has ended here. For more other exciting content, you can pay attention to the laravel video tutorial column on the PHP Chinese website!

The above is the detailed content of Summary of laravel common path saving (with code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete