How do you load config settings from the database in Symfony2?

后端 未结 2 1668
说谎
说谎 2021-01-31 00:39

I have a number of settings that are currently in the config.yml file.

Going forward I want to be able to develop an interface where administrators will be able to updat

相关标签:
2条回答
  • 2021-01-31 00:46

    There's a cookbook article that explains roughly how to do this (albeit briefly), in reference to loading in settings externally from Drupal. The basic idea is to do something like this in your config (example is yml):

    # app/config/config.yml
    imports:
        - { resource: parameters.php }
    

    then in parameters.php you can do whatever you need to to get your config, and set it as follows:

    $container->setParameter('my.db.parameter', $value);
    

    (taken from the cookbook, slightly modified).

    0 讨论(0)
  • 2021-01-31 00:54

    Take a look at the UnifikDatabaseConfigBundle. It creates a database structure that enable configuration of Symfony parameters straight from the database.

    0 讨论(0)
提交回复
热议问题