Jun
10
2010
8

Per-environment fixtures in symfony

UPDATE:

I have now packaged this script into a symfony plugin called sfEnvironmentFixturesPlugin. Check it out and hit the ‘I use it’ link if you find it useful!

Feel free to leave questions, comments, and bug reports in the comments.

Symfony‘s fixtures are a great way to set up initial data and/or test data for a system. Whenever I create a new symfony project however, I always find myself wishing there was an easy way to specify which fixtures contain data required for production systems (the ‘initial’ data) and which contain data that I only need when developing (the ‘test’ data).

I recently started such a project and came across a reasonably elegant solution. With a simple YAML file placed in your fixtures directory, you too can have such a set up if so desired.

(more…)