Standalone configuration file
The new version supports profile separation and requires only configuration extra_config_list
parameters (in the application public profile).
For example, if you do not use a standalone configuration file, the database configuration information should be configured in config.php as follows:
/* Database Settings */' Database ' = [Database type' type ' = =' MySQL ',Server address' Hostname ' =' 127.0.0.1 ',Database name ' database ' = ' thinkphp ', // Database user name ' username ' + ' root ', // Database password ' password ' + ", // Database connection Port ' hostport ' + ", // Database connection Parameters ' params ' = = [], //database encoding by default UTF8 ' charset ' = ' UTF8 ', //database table prefix prefix ' = ", //database debug mode ' debug ' = false,],
If you need to use a standalone configuration file, first add the configuration in config.php:
‘extra_config_list‘ => [‘database‘],
After the definition, the database configuration can use database.php
the file independently, the configuration content is as follows:
/* Database Settings */return [Database type' type ' = =' MySQL ',Server address' Hostname ' =' 127.0.0.1 ',Database name ' database ' = ' thinkphp ', // Database user name ' username ' + ' root ', // Database password ' password ' + ", // Database connection Port ' hostport ' + ", // Database connection Parameters ' params ' = = [], //database encoding by default UTF8 ' charset ' = ' UTF8 ', //database table prefix prefix ' = ", //database debug mode ' debug ' = false,],
If you have configuredextra_config_list
Parameters, and at the same timeconfig.php
Anddatabase.php
Are configured in the file, thedatabase.php
The configuration of the file overridesconfig.php
Settings in the.
parameter acquisition of the standalone configuration file is a two-dimensional configuration, for example, to obtain database
type
parameter, which should be:
Config::get(‘database.type‘);
To obtain the parameters for a complete stand-alone profile, use:
config:: Get (
The system defaults to 2 separate configuration files, including database
and validate
, for setting the database configuration and validation rule definitions, respectively.
thinkphp5.0 Standalone Configuration