Development

HowToHandleCrossAppsConfigurationFiles

You must first sign up to be able to contribute.

Version 4 (modified by smeves, 10 years ago)
added note about global config/app.yml file

How to manage your own cross-apps/global configuration values

If you want a global configuration file with a nice accessor preffix (ef. project_), you can use the sfDefineEnvironmentConfigHandler class and a specific param in a custom <project_root>/config/config_handlers.yml file, like this :

config/project.yml:
  class:    sfDefineEnvironmentConfigHandler
  param:
    prefix:  project_

You will now have to append these lines to the ./<appname>/config/config.php of every app you want to be able to access config values from :

require_once sfConfigCache::getInstance()->checkConfig('config/project.yml');

Below a sample config/project.yml file :

all:
  section:
    value: It works !

You'll now be able to call these cross-apps config values like this :

<?php
echo sfConfig::get('project_section_value', 'It does not work'); // prints "It works !"
?>

Alternatively, if you don't mind accessing these cross-application settings with the accessor prefix "app", you can place them in your project's config/app.yml (not the individual application app/config/app.yml file).