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

Summary of laravel common path saving (with code)

不言
Release: 2019-03-26 10:56:33
forward
2840 people have browsed it

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();
Copy after login

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');
Copy after login

base_path()

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

$path = base_path();
Copy after login

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');
Copy after login

config_path()

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

$path = config_path();
Copy after login

database_path()

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

$path = database_path();
Copy after login

public_path ()

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

$path = public_path();
Copy after login

storage_path()

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

$path = storage_path();
Copy after login

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');
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template