• December, 2011
  • . Posted by jpgranja

Symfony custom configuration files

First, let’s create a custom configuration file, for instance, config/extra_configs.yml , in the project main directory, not the app config directory.

prod: 
  name_1: ok 
 
dev: 
  name_2: ko 
 
all: 
  john: hello 
  doe: hello

After that you need create/update a config handler YAML file (config/config_handlers.yml)

config/extra_configs.yml:
  class:    sfDefineEnvironmentConfigHandler
  param:
    prefix: extra_

Finally you need to register the new configuration file in all applications you want. To do so you need to update your application configuration class (apps/frontend/config/frontendConfiguration.class.php).

public function configure()
{
  ....
  require_once($this->getConfigCache()->checkConfig('config/extra_configs.yml'));
}

Now all config options defined in the new file are available in the application with the extra_ prefix.

sfConfig::get("something_foo");
Posted in : Programming, symfony
Tags: , ,

Leave a Reply