How to create a custom yaml config file in Symfony

Posted by Guillaume Flandre on Stack Overflow See other posts from Stack Overflow or by Guillaume Flandre
Published on 2010-03-30T10:56:01Z Indexed on 2010/04/07 7:53 UTC
Read the original article Hit count: 421

What I want to do is quite simple: store data in a custom config file that I want to read later on.

I created my file something.yml that I put in the global config directory. It looks like that:

prod:
  test:  ok

dev:
  test: ko

all:
  foo:  bar
  john: doe

Then I copied the config_handlers.yml and also put it in the config directory and added the following at the top of the file:

config/something.yml:
  class:    sfDefineEnvironmentConfigHandler
  param:
    prefix: something_

But if I'm calling sfConfig::get("something_foo"); I keep getting NULL.

What did I do wrong? I just want to read values, so no need to create a custome config handler, right?

I've read the doc here: http://www.symfony-project.org/book/1_2/19-Mastering-Symfony-s-Configuration-Files even though I'm running 1.4 (I don't think that changed since then).

Edit: Of course I can use sfYaml::load() but I'd like to do things in a better way.

© Stack Overflow or respective owner

Related posts about symfony

Related posts about symfony-1.4