I recently found on Coil’s blog, here: http://www.strangebuzz.com/post/2012/01/28/Load-fixtures-with-Symfony2 how he went about creating fixtures from Yaml files in Symfony2. This is something that I’ve been willing to have for a while.
But I needed more than just loading the data from Yaml. My need for easy to use fixtures comes from testing and setting up the database for test purposes. Fixtures can have many different needs. You might need some of them in production because they bootstrap your database (for example set the client_contract possible status to prospect, proposal, signed_contract in a contract_status table), some of them are required for development. And some of them for testing of course and for testing you might even want different possible cases.
Based on this idea I created a new bundle for this purpose: https://github.com/khepin/KhepinYamlFixturesBundle
The bundle allows you to define fixture files in the YAML format of course. You have a command line tool to load all your fixtures in database. As well as a service living in the DIC so that you can load fixtures in your test setup function.
The bundle provides a notion of “contexts” which might be the ‘production’, ‘test’, ‘dev’ cases we just talked about for example. This allows you to either load only the standards fixtures or load the standard ones plus the ones specific of a given context.
Well that’s it for now, but I hope it helps many of you I’ve seen looking for this on the interwebs. Any feedback is welcome to help make it more usable for not just me.