Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of how to use the Symfony Config component
// Load application-specific configuration
try {
$basepath = __DIR__ . '/config';
$configuration = Yaml::parse($basepath . '/config.yml');
} catch (\InvalidArgumentException $exception) {
exit("Are you sure the configuration files exist?");
// Use a Symfony ConfigurationInterface object to specify the *.yml format
$yamlConfiguration = new \Configuration();
// Process the configuration files (merge one-or-more *.yml files)
$processor = new Processor();
$configuration = $processor->processConfiguration(
array($configuration) // As many *.yml files as required
* The class to handle the *.yml configuration should look
* something like this...
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
class Configuration
* @return TreeBuilder
public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('arbitary');
return $treeBuilder;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.