This article mainly introduces the thinkPHP5.0 framework environment variable configuration method, and analyzes the function, definition, configuration and related environment variables in thinkPHP5.0 in the form of examples. Notes, friends who need it can Refer to the example below
This article describes the thinkPHP5.0 framework environment variable configuration method. Share it with everyone for your reference, the details are as follows:
Allows the use of environment variable configuration, and the priority level is higher than in the configuration file, because when reading the configuration parameters, it will first determine whether the environment variable exists This configuration.
During the development process, you can simulate environment variable configuration in .env under the application root directory. The configuration parameter definition format in the .env file adopts the ini method , for example:
app_debug = true app_trace = true
If your deployment environment has separately configured environment variables, please delete the .env configuration file to avoid conflicts.
Environment variable configuration parameters will all be converted to uppercase, with a value of null, no and false are equivalent to "", and yes and true are equivalent to "1".
The default environment variable prefix of ThinkPHP5.0 is PHP_, which can also be reset by changing the ENV_PREFIXconstant.
Note,Environment variables do not support arrayparameters. If you need to use array parameters, you can use underscores to separate the configuration parameter names:
database_username = root database_password = 123456
[database] username = root password = 123456
Config::get('database.username'); Config::get('database.password'); // 同时下面的方式也可以获取 Config::get('database_username'); Config::get('database_password');
The above is the detailed content of Detailed explanation of thinkPHP5.0 framework environment variable configuration example code. For more information, please follow other related articles on the PHP Chinese website!