====== Symfony YAML Configuration Reference ====== ===== The app.yml configuration file ===== In this article we assume that you are familiar with [[http://www.symfony-project.org/reference/1_4/en/02-YAML|The YAML Format]] and [[http://www.symfony-project.org/reference/1_4/en/03-Configuration-Files-Principles|Configuration File Principles]]. The symfony framework provides a built-in configuration file for application specific settings, the //app.yml// configuration file. The //app.yml// configuration file is a great place to define settings that change based on the environment (an API key for instance), or settings that can evolve over time (an email address for instance). It is also the best place to define settings that need to be changed by someone who does not necessarily understand symfony or PHP (a system administrator for instance). env_name: setting_name: setting_value setting_group_name: setting_name: setting_value ===== Configuration options ===== ==== env_name ==== The //app.yml// file is environment-aware, therefore you can add configurations for different environments by specifying environment name (eg.: //prod//, //test//) or '//all//' for all environments. ==== env_name > setting_name ==== This //app.yml// file can contain any setting you want that makes sense for your specific application, eg.: all: active_days: 30 default_items_per_page: 50 In the code, these settings are available through the global //sfConfig// class, and keys are prefixed with the //app_// string: sfConfig::get('app_active_days'); sfConfig::get('app_default_items_per_page'); ==== env_name > setting_group_name > setting_name ==== Sometimes, when you have a lot of settings, you may want to group them. For example you can add groups '//products//' and '//clients//' respectively for Products view and Clients views: all: products: items_per_page: 50 allow_negative_remain: false clients: items_per_page: 100 In the code, these settings are available through the global //sfConfig// class, keys are prefixed with the //app_// string and setting groups are concatenated with underscores ('_'): sfConfig::get('app_products_items_per_page'); sfConfig::get('app_products_allow_negative_remain'); sfConfig::get('app_clients_items_per_page'); When you should require an PHP array directly beneath the all key you need to use a category header, otherwise symfony will make the values separately available as shown above. all: .array: creditcards: fake: off visa: on americanexpress: on print_r(sfConfig::get('app_creditcards')); Array( [fake] => false [visa] => true [americanexpress] => true )