Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I generate Symfony fixtures YML from exising database data?

I was wondering if anyone knew how to generate a fixture.yml from data that is already existing in the database?

As you can use the build-schema to generate a schema, is there a way to do that for data?

symfony propel:build-schema
like image 868
frodosghost Avatar asked Nov 25 '09 23:11

frodosghost


People also ask

What are symfony fixtures?

Fixtures are used to load a "fake" set of data into a database that can then be used for testing or to help give you some interesting data while you're developing your application. This bundle is compatible with any database supported by Doctrine ORM (MySQL, PostgreSQL, SQLite, etc.).

What is Doctrine repository?

A repository in a term used by many ORMs (Object Relational Mappers), doctrine is just one of these. It means the place where our data can be accessed from, a repository of data. This is to distinguish it from a database as a repository does not care how its data is stored.

What is symfony repository?

A repository is a way to retrieve entities, so put on repositories any method you need to get them, such as getUserByEmail or whatever.

What is schema symfony?

In order to create the data object model that symfony will use, you need to translate whatever relational model your database has to an object data model. The ORM needs a description of the relational model to do the mapping, and this is called a schema.


2 Answers

In symfony 1.4 you just need to write:

./symfony doctrine:data-dump

and you get the file data/fixtures/data.yml

:-)

like image 196
tuffo19 Avatar answered Sep 23 '22 20:09

tuffo19


I found a solution in a mail archive. The user uses

symfony propel:data-dump > fixture.yml
like image 29
Felix Kling Avatar answered Sep 26 '22 20:09

Felix Kling