Ask your Symfony questions! Pay money and get answers fast! (more info)

Where is app.yml loaded, and how can I force it to load elsewhere Symfony

  • SOLVED

Assume I have a app.yml file here:

apps/frontend/config/app.yml

But I want to give my customers the ability to use my software to customize their own sites. They will have a web form that they can access, and through which they can fill in their own values for app.yml. This new file will be written to a new location:

/home/zebulon/custom/app.yml

Once this new file exists, how do I get Symfony to load it, instead of the default file? What core file do I need to hack to make this happen?

Answers (3)

2010-11-26

Arturo Linares answers:

You can always read a YML file using sfYaml::load().

For this case, I think you could write a class for custom properties; it would load a custom yml file using sfYaml class and save them using sfConfig::set() to make them accessible everywhere in the site. This functionality could be set as a filter also.

2010-11-26

Cristian Baciu answers:

Hi,

you can put this line on your apps/frontend/config/app.yml file:

<?php include ('/home/zebulon/custom/app.yml'); ?>

Or you can do this on the application level:
<em>(file: apps/frontend/config/frontendConfiguration.class.php)</em>

<?php

class frontendConfiguration extends sfApplicationConfiguration
{
public function initialize()
{

require($this->getConfigCache()->checkConfig('/home/zebulon/custom/app.yml'));
}
}


Cristian

2010-11-27

Jakub Zalas answers:

Similar functionality is already implemented as a [[LINK href="http://www.symfony-project.org/plugins/ysfDimensionsPlugin"]]ysfDimensionsPlugin[[/LINK]].

The plugin allows you to split configuration among several files based on a dimension. Dimension might be a culture, user name, domain or whatever you want. In case dimension specific file doesn't exist the default one is used.

Example: you have a <em>apps/frontend/config/app.yml</em> file. If a user name is your dimension than you can (but don't have to) add separate files for each of the users - like <em>apps/frontend/config/zebulon/app.yml</em> or <em>apps/frontend/config/kuba/app.yml</em>.

Only thing you need to do is to figure out how to make that user specific configuration file is searched outside of a symfony dir. So it would look for <em>/home/zebulon/custom/app.yml</em> instead of <em>apps/frontend/config/zebulon/app.yml</em>.

I think it should be relatively easy as it's just a matter of overloading or changing part of the plugin which looks for a dimension specific file.