Nerds who love the symfony-project
6 Mar
One of the things that might not be clear to Symfony developers is when to use app.yml for your application config and when to use project-level configuration for all your applications.
If your configuration parameter is for all your applications you should place this configuration setting within your config/ProjectConfiguration.class.php (Symfony 1.2.x). This will save you duplicating the config within each app’s app.yml and you only have to specify it once.
Setting up project-level config
You can set project-wide config by editing this file.
.... class ProjectConfiguration extends sfProjectConfiguration { public function setup() { //In my example below I want to tell my app if it should use a proxy or not sfConfig::set('use_proxy', '1'); //1 = True, 0=False $this->enableAllPluginsExcept(array('sfDoctrinePlugin', 'sfCompat10Plugin')); } }
Anything you place in your project-level config can be accessed from any application (or Symfony task) by using the standard sfConfig::get() static method.
Note: You would normally have to get the application context if you want to read an application config within a Symfony Task. In this case, you wouldn’t because the config is set at a project level.
4 Responses for "Quick Symfony Tip: Project Level Config or App Level Configuration?"
For those that are interested, I have raised a feature request to make the project-level config and app-level config consistent.
Details of the proposal can be found here: http://trac.symfony-project.org/ticket/6034
Please vote/contribute if you can.
[...] application configuration can be configured for each application in the app.yml file. One of they key problems with this is if you want an end-user to be able to change some of [...]
Hi
You can also use an app.yml located in sf_root_dir/config.
It will be merged with the app.yml file of your application.
I second Eric’s approach of a “global” app.yml
It seems dumb to create an “app” file outside of an application but it does work. I’m using it to have project wide settings such as the current VAT rate.
Leave a reply