Symfony 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 this application configuration, they can’t. You would need to do that for them.

A good way to fix this is to store your applications configuration in the database. This comes with a performance cost (extra calls to your database) - so its up to you to decide if this is the most efficient solution for you.

Here is an outline on how to get started building your application’s config in the database.

Step 1: Define your model
Create the columns you want to store for your application config. In this instance, we are just going to store name and value pairs (ie Attribute & Value). Here is a sample below:

propel:
  #Application configuration table
  my_app_config:
    _attributes:                { phpName: MyAppConfig }
    id:                         { type: integer, required: true, primaryKey: true, autoIncrement: true }
    attribute:                  { type: varchar(255) }
    value:                      { type: varchar(255) }
...

Once you have finished that, go ahead and build your model

Step 2: Extend Your MyAppConfig class
So the next step is for us to make it easy to access application configuration. For us to do this, go to your lib/model/MyAppConfig.class.php and extend your base class as follows:

<?php
class MyAppConfig extends BaseMyAppConfig
{
 
  /**
   * Returns a value of an attribute string for my app's config table
   * @param string attribute name
   * @return string The value of that attribute
   * @author eHabib
   */
	public function lookupValueFromAttribute($attribute){
  		$c = new Criteria();
  		$c->add(MyAppConfigPeer::ATTRIBUTE, $attribute);
  		$result = new MyAppConfig();
  		$result = MyAppConfig::doSelectOne($c);
		return ($result->getValue());
	}
}

Step 3: Use it!
Let’s say that in our database we have the following attribute/value paris:

Attribute: app_support_email, Value: myemail@mydomain.com
Attribute: app_base_url, Value: http://whatever

You could access this data in your code by doing this:

$myConfig = new MyAppConfig();
$appEmail = $smyConfig->lookupValueFromAttribute("app_support_email");
$appURL = $smyConfig->lookupValueFromAttribute("app_base_url");
...
echo $appEmail.",".$appURL; //lets print it

That’s it!

Step 4: Configure it via your front-end
The last step (if you wish) is to allow the end-user to update the value of these fields. To do this, you can build a form to update these fields, or use Symfony’s admin generator.