Skip to content

Environment variables

The project uses the .env file to configure variables that depend on the running environment, such as database, Redis parameters, and so on.

IMPORTANT

copy test.env to .env and modify the configuration parameters

Use php's native getenv function to get configuration parameters in the program.

WARNING

The parameters in .env are very sensitive, so you should add .env to the .gitignore file to avoid being submitted to the code base and lead to disclosure.

  • in the production environment, you should configure parameters that are different from the development environment according to the actual situation.

time Zone configuration

  • TIME_ZONE

    specify the project time zone. The default is Asia/Shanghai, which can be modified according to the actual situation. If you do not need to modify it, delete this line. For fully supported parameters, please refer to https://www.php.net/manual/zh/timezones.php

Database configuration

  • DB_HOST

    the database host address should be modified according to the actual situation. Once set, the program will automatically connect to the database at initialization. If the project does not need to connect to the database, please leave it blank or delete it.

  • DB_PORT

    the database port can be modified according to the actual situation. Defaults to 3306 when not set

  • DB_NAME

    the name of the database, which is modified according to the actual situation.

  • DB_CHARSET

    the database character set, which is modified according to the actual situation. Defaults to utf8mb4 when not set

  • DB_USER

    the user name of the database should be modified according to the actual situation. Defaults to root when not set

  • DB_PASSWORD

    the database password should be modified according to the actual situation. Default is empty when not set.

  • DB_DRIVER

    the database driver can be modified according to the actual situation. Defaults to mysql when not set

  • DB_PREFIX

    the database table prefix is modified according to the actual situation. There is no prefix by default when it is not set.

Redis configuration

  • REDIS_HOST

    Redis CVM address, which is modified according to the actual situation. Once set, the program will automatically connect to Redis during initialization. If the project does not need to connect to Redis, please leave it blank or delete it.

  • REDIS_PORT

    Redis port, which is modified according to the actual situation. Defaults to 6379 when not set

  • REDIS_DB

    the Redis database can be modified according to the actual situation. Defaults to 0 when not set

  • REDIS_PREFIX

    the prefix of Redis key, which is modified according to the actual situation. There is no prefix by default when it is not set.

other configurations

You can add other configuration parameters that depend on the running environment as needed, such as API keys, interface parameters, etc., these values should not be part of the program code.