官术网_书友最值得收藏!

The configuration files

Each application has a need to hold some global and machine-specific parameters and configurations. Symfony2 holds configuration within the app/config directory and it is split into a few files as follows:

  • config.yml
  • config_dev.yml
  • config_prod.yml
  • config_test.yml
  • parameters.yml
  • parameters.yml.dist
  • routing.yml
  • routing_dev.yml
  • security.yml
  • services.yml

All the files except the parameters.yml* files contain global configuration, while the parameters.yml file holds machine-specific information such as database host, database name, user, password, and SMTP configuration.

The default configuration file generated by the new Symfony command will be similar to the following one.

This file is auto-generated during the composer install:

parameters:
 database_driver: pdo_mysql
 database_host: 127.0.0.1
 database_port: null
 database_name: symfony
 database_user: root
 database_password: null
 mailer_transport: smtp
 mailer_host: 127.0.0.1
 mailer_user: null
 mailer_password: null
 secret: 93b0eebeffd9e229701f74597e10f8ecf4d94d7f

As you can see, it mostly holds the parameters related to database, SMTP, locale settings, and secret key that are used internally by Symfony2. Here, you can add your custom parameters using the same syntax. It is a good practice to keep machine-specific data such as passwords, tokens, api-keys, and access keys within this file only. Putting passwords in the general config.yml file is considered as a security risk bug.

The global configuration file (config.yml) is split into a few other files called routing*.yml that contain information about routing on the development and production configuration. The file called as security.yml holds information related to authentication and securing the application access. Note that some files contains information for development, production, or test mode. You can define your mode when you run Symfony through the command-line console and when you run it through the web server. In most cases, while developing you will be using the dev mode.

主站蜘蛛池模板: 滦南县| 休宁县| 长白| 淅川县| 夏津县| 沙雅县| 阳高县| 连江县| 石台县| 蓝山县| 武强县| 慈利县| 咸宁市| 甘泉县| 喀喇| 化隆| 余庆县| 平安县| 蒙阴县| 五指山市| 静宁县| 广平县| 贺兰县| 福安市| 和平区| 海南省| 远安县| 泸西县| 鄂尔多斯市| 乐至县| 中江县| 德钦县| 通榆县| 阳朔县| 大荔县| 西宁市| 林芝县| 分宜县| 揭阳市| 祁门县| 安仁县|