PHP framework laravel. env file configuration tutorial,
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*******
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.