Using a custom config file with symfony 1.2/1.4

If you want to store some parameters in your own configuration file (other than /config/app.yml for different reasons) with your very own prefix, you just have to create a /config/config_handlers.yml file :

config/my_config_file.yml:
  class:    sfDefineEnvironmentConfigHandler
  param:
    prefix: myprefix_

Now, symfony will process your config file with sfDefineEnvironmentConfigHandler and add your parameters to global settings values with myprefix_ prefix. Don't forget to tell symfony to include your file, in your application configuration file (/app/myapp/config/myappConfiguration.class.php) :

<?php

class myappConfiguration extends sfApplicationConfiguration
{
  /* ... */

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

You can have more information about symfony internals by checking the /cache/myapp/myenv/config/config_settings.yml.php file.

post a comment