- Symfony2 Essentials
- Wojciech Bancer
- 276字
- 2021-07-16 20:06:58
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.
- C++面向?qū)ο蟪绦蛟O計(第三版)
- Spring Cloud Alibaba微服務架構(gòu)設計與開發(fā)實戰(zhàn)
- Rust編程:入門、實戰(zhàn)與進階
- Bootstrap 4:Responsive Web Design
- 小程序開發(fā)原理與實戰(zhàn)
- Modern JavaScript Applications
- PHP 7+MySQL 8動態(tài)網(wǎng)站開發(fā)從入門到精通(視頻教學版)
- R語言與網(wǎng)絡輿情處理
- SQL Server 2016 從入門到實戰(zhàn)(視頻教學版)
- Mastering Bootstrap 4
- Java程序設計入門(第2版)
- RESTful Web API Design with Node.js
- 算法訓練營:海量圖解+競賽刷題(入門篇)
- Python程序設計教程
- Scratch超人漫游記:創(chuàng)意程序設計:STEAM創(chuàng)新教育指南