Home >PHP Framework >Laravel >Why does laravel use env?

Why does laravel use env?

青灯夜游
青灯夜游Original
2021-09-17 13:56:231885browse

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!

Statement:
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