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

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

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

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?

This question has been answered.

Lawrence Krubner | 11/26/10 at 1:24pm Edit

Previous versions of this question: 11/27/10 at 11:40pm | 11/27/10 at 11:41pm | 11/27/10 at 11:54pm

The experts have suggested, on average, a prize of $10 for this question.

(3) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    11/30/10
    10:02pm
    Arturo Linares says:

    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.

  • avatar
    Last edited:
    11/30/10
    10:02pm
    Cristian Baciu says:

    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:
    (file: apps/frontend/config/frontendConfiguration.class.php)

    <?php

    class frontendConfiguration extends sfApplicationConfiguration
    {
    public function initialize()
    {

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


    Cristian

    Previous versions of this answer: 11/26/10 at 1:55pm

  • avatar
    Last edited:
    11/30/10
    10:02pm
    Jakub Zalas says:

    Similar functionality is already implemented as a ysfDimensionsPlugin.

    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 apps/frontend/config/app.yml 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 apps/frontend/config/zebulon/app.yml or apps/frontend/config/kuba/app.yml.

    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 /home/zebulon/custom/app.yml instead of apps/frontend/config/zebulon/app.yml.

    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.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.