thinkphp5.0 Standalone Configuration

Source: Internet
Author: User

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_listParameters, and at the same timeconfig.phpAnddatabase.phpAre configured in the file, thedatabase.phpThe configuration of the file overridesconfig.phpSettings 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.