News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Joshua Thijssen:
Custom symfony2 config loader
January 30, 2013 @ 11:51:47

In his latest post Joshua Thjissen looks at the creation of a custom configuration loader for a Symfony2 application. This kind of thing is mostly useful for parsing configurations that Symfony2 doesn't already know how to parse.

It happens more and more: large projects where your symfony2 site is just a small part in the big picture. Lots of additional components might even play a bigger part, especially when you are dealing with asynchronous components which are connected through message queues for instance. [...] Our first idea is obvious: symfony2 uses by default a parameters.yml file, which gets imported by your configuration (config.yml) [...] So nothing new here and this setup works perfectly, provided that your symfony2 project is the ONLY thing that needs to be configured. As soon as you add multiple other components (like gearman or activemq workers that need to connect to solr too), they need to share this configuration.

His solution involves falling back to the INI-file format that's known as useful for several different languages and tools. Because of how Symfony2 reads these files though (only looking for "parameters") he's had to create a "ConfFileLoader" instance of the "FileLoader" that uses the parse_ini_file method to parse the data and return it back to the main container as parameters. He also includes the code/config you'll need to implement this custom loader into your application.

0 comments voice your opinion now!
custom loader symfony2 configuration file ini loader


blog comments powered by Disqus

Similar Posts

PHP 10.0 Blog: Namespaces FAQ

Fabien Potencier: Packing a Symfony full-stack Framework Application in one File - Bootstrapping

Gonzalo Ayuso: Handling several DBALs in Symfony2 through the Dependency Injection with PHP

Raphael Stolt's Blog: Two Zend_Log Posts

Alvaro Videla's Blog: Integrating Facebook Hive with Symfony


Community Events





Don't see your event here?
Let us know!


tips deployment interview opinion release series community laravel install update api package list library framework introduction language symfony podcast zendserver

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework