Home > PHP Framework > Laravel > body text

Why does laravel use env?

青灯夜游
Release: 2023-01-13 00:40:24
Original
1859 people have browsed it

The reasons why laravel uses env: 1. Separate files from code to avoid submitting sensitive information to open source communities such as Github; 2. Form a unified specification. People who are new to the project only need to have read the framework. You can know what environment variables need to be configured by reading the manual or touching the ".env" file.

Why does laravel use env?

The operating environment of this tutorial: Windows 7 system, Laravel 6 version, Dell G3 computer.

Laravel uses the DotEnv library. The reasons for using .env are written on the README, which are roughly as follows:

  • Separation of files and code To avoid submitting sensitive information to open source communities such as Github, version controllers are generally configured to ignore this file;

  • Form a unified specification, use configuration files for different environments It can also have a similar effect, but it may cause that there is no unified naming. LocalConfig.php is used in project A and TestConfig.php is used in project B. If the .env file is used, people who are new to the project will only have to read the framework. You can know the environment variables that need to be configured by reading the manual or coming into contact with the .env file;

Note: There is a certain performance overhead in loading the .env file, and projects with high performance requirements , it is best to merge the .env file into the code through tools when publishing to the online production environment.

Related recommendations: The latest five Laravel video tutorials

The above is the detailed content of Why does laravel use env?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template