While developing an application in Symfony , You might want to run some part of your code in development environment and other part in production environment. In such situation you can use sfConfig::get class to get the environment in which your application is running, And you can use this as a condition to run your code.
web/index.php is the file where you declare your Symfony environment:
Now you can get the environment using following:
$sf_environment variable will return string as ‘prod’ and you can use it as condition
In-fact you can use sfConfig::get to access any configuration of your application declared in yml files.
Happy Coding…..
More than 3 requests, I'll translate this to Chinese.
超过3个请求,我就会把这篇文章翻译成中文。
1 comment:
To get all available options: getAll()
To get current application: get('sf_app')
Post a Comment