投稿日:2010年7月30日(この記事を読むのに必要な時間: 約 1分19秒)
app.ymlにこんな風に書くと、
all: config: test: hogehoge
コードの中では
sfConfig::get('app_config_hogehoge');
という感じでとってこれる。
設定値が多いとapp.ymlに書いていると見通しが悪くなるので、独自にgame.ymlをつくって値を持つようにする。
./config/config_handlers.yml
config/game.yml: class: sfDefineEnvironmentConfigHandler param: prefix: game_
./config/game.yml
all: config: test: hogehoge
./config/frontendConfiguration.class.php
class frontendConfiguration extends sfApplicationConfiguration { public function configure() { require_once $this->getConfigCache()->checkConfig('config/game.yml'); } }
こうすると、コードでこんな風に取れる。
sfConfig::get('game');
