This document discusses best practices for configuring bundles in Symfony applications. It recommends structuring configuration with bundles, parameters, and options in a YAML file. It also emphasizes validating configuration types, values, and required fields. The document explains how to build a configuration tree and load configuration to inject dependencies and configure services.
7. app/config.yml
parameters:
global.page_size: 10
gloabl.page_num: 5
global.tracking.key: ASFDIPSADPFIHwer234123QSD
# Various configuration
webservices.timeout: 100
content_check.enabled: true
birthdates.start: 1950 # TODO: Delete after release
logging.registrations: true
# Tracking Bundle Configuration
trackingbundle.user: rebum
trackingbundle.api.version: 1_0
trackingbundle.use_ssl: true # Do not touch this!!!
trackingbundle.track_super_users: false
infobundle.god_mode: true # Ticket 123456234
infobundle.level: 42
# Connection data for some service
some_webservice.url:
some_webservice.user:
This file was much
http://example.com
api
some_webservice.key: Sdfihwef $5sdf” SAFAWEF
some_webservice.ssl: true loooooonger…
# More configuration
more.config: 100
even.more.config: true
oh_my_option: 123
foo.bar.baz: true
application.lock_user: super
misc.timeout: 300
http.meta.title: super page
http.meta.keywords:
- some
- keywords
- for
- this
- page
http.description: Some crazy description for the homepage that we all love so much
#...
8. app/config.yml
parameters:
global.page_size: in
All one context
10
gloabl.page_num: 5
global.tracking.key: ASFDIPSADPFIHwer234123QSD
# Various configuration Correct type?
webservices.timeout: '100'
content_check.enabled: true
birthdates.start: 1950 # TODO: Delete after release
logging.registrations: true
# Tracking Bundle Configuration
trackingbundle.user: rebum Only this bundle?!
trackingbundle.api.version: 1_0
trackingbundle.use_ssl: true # Do not touch this!!!
trackingbundle.track_super_users: false
infobundle.god_mode: true # Ticket 123456234
infobundle.levl: 42
# Connection data for some service
some_webservice.url: http://example.com
some_webservice.user: api Multiple connections?!
Correct key?!
some_webservice.key: Sdfihwef $5sdf” SAFAWEF
some_webservice.ssl: true
45. connection:
url: http://example.com
user: api
key: $ome35ecre7Ke$
46. Group of nodes
->arrayNode('connection')
->children()
->scalarNode('url')
->isRequired()
Specific validation
->end()
->scalarNode('user')->end()
->scalarNode('key')->end()
->end()
->end()