Creating a Symfony 2 Settings Manager

Often you need a way to enable the user to edit some application settings like contact emails, site themes or social media links, so that you don't have to alter the code each time your admin user changes their email address. In one of our systems we needed a lot of such settings. That's when the idea of a Settings Manager came to life. The intent behind it was to create a way of exposing certain parameters to the user in a way that would be managable and extensible. At first we wanted to make <strong>app/config/parameters.yml</strong> editable, but that would expose too much sensitive information. As we all know, the user can not be trusted with sensitive or delicate data. Sooner than later, they would introduce a typo to some vital parameter, and the whole application would crash. With this option closed, we thought of making a database-based settings object that would hold this problematic data, but this option wasn't extensible enough. Adding another setting would require to add another column to the database table. So we ended up with creating a custom file-based YAML settings manager and a custom class to handle the input.<br/> This article will show you how to create such a manager and how to incorporate it into your own application.