In earlier versions, Laravel used the php file in the config folder to complete the configuration required for the project. later, it used. env to place some configurations from about 5. The following article describes the configuration of the. env file of laravel, a PHP Framework. For more information, see. In earlier versions, Laravel used the php file in the config folder to complete the configuration required for the project. later, it used. env to place some configurations from about 5. The following article describes the configuration of the. env file of laravel, a PHP Framework. For more information, see.
Preface
We should all know that when using the laravel framework to develop PHP programs, the framework is configured. the env file is crucial. you need to configure the database, database users, and cache for this file. let's take a look at the detailed configuration tutorial.
1. configure APP_KEY
The laravel framework hardcoded symmetric encryption keys in the. env configuration file by default. The same APP_KEY is not required in the development and production environments and must be strictly prohibited.
Run in projectphp artisan key:generate
The key is automatically generated in the. env file.
APP_KEY=Li0zqXhuxOlnsMtG90UsU**********
2. configure database and database users
(1) create a database
Use commandsmysql < init_db.sql
Execute scripts to create a database
(2) create a database user
Use commandsmysql < create_usr.sql
Run the script to create a user
CREATE two users here. one cloudlab_dev user has the Insert, Select, Delete, Update, and CREATE permissions.
A cloudlab_dba has the Insert, Select, Delete, Update, ALTER, CREATE, DROP, INDEX, and LOCK permissions.
Generally, cloudlab_dev is used, and cloudlab_dba is used for table creation.
Result:
DB_HOST=127.0.0.1DB_DATABASE=cloudlabDB_USERNAME=cloudlab-devDB_PASSWORD=cloudla******DB_USERNAME_DBA=cloudlab-dbaDB_PASSWORD_DBA=cloud*******
The above is the detailed description of the. env file configuration tutorial of the laravel framework. For more information, see other related articles in the first PHP community!