Note: this post was written when i was working on V1.1 or V1.2. Please scroll down to read updated note before you try anything.
While developing a symfony project, it’s usually required to rebuild database and reload data constantly with ‘symfony propel:build-all‘ or ‘symfony propel:build-all-load‘ constantly. When this is run, test data are wiped.
The easy way is to have initial test data in data/fixtures. But not sure how to write it in yml format?
Once the data are entered into the project, data can by exported by running ‘symfony propel:data-dump‘ to dump data in yml format. The default output is on screen. Redirect the output to a file, edit and move it to your-project/data/fixtures.
From then on all build-all-load will load these data into the database.
If you use doctrine, replace ‘propel’ in above commands to ‘doctrine’.
As of v1.4 doctrine is the default and I’m using it from now on.
The build commands mentioned above have deprecated and changed to:
- symfony doctrine:build –all
- symfony doctrine:build –all –and-load
The dump command now dumps data to a file in data/fixtures.