Ona
Ona

Reputation: 35

How do I generate Symfony 2 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 ?

Upvotes: 2

Views: 900

Answers (2)

Maycon Vinicius
Maycon Vinicius

Reputation: 101

You could use https://github.com/nelmio/alice

Example:

Nelmio\Entity\Group:
    group1:
        name: Admins
        owner: '@user1'
        members: '<numberBetween(1, 10)>x @user*'
        created: '<dateTimeBetween("-200 days", "now")>'
        updated: '<dateTimeBetween($created, "now")>'

Upvotes: 0

dlondero
dlondero

Reputation: 2597

The times of using YAML for data fixtures is no longer. Instead, you are only required to use plain PHP for loading your data fixtures.

The yaml fixtures have a lot of inherit problems that can never really be fixed. They are just "known problems", not to mention the fact that it is much slower to import a lot of data fixtures when using yaml. The trade off is super simple ease of use for something that works 100% and is stable.

Upvotes: 2

Related Questions