7

I'm developing a web site with Symfony. I'm new on this framework. Before i used Laravel 5.0 and I need to have a database with rows.

I create my db with command prompt but now I don't find how to seed it.

There is a equivalent of Laravel seeders on Symfony?

dario
  • 5,149
  • 12
  • 28
  • 32
hemir
  • 93
  • 1
  • 1
  • 6

3 Answers3

6

No. Seeding was a feature added by Laravel. You’ll need to use a third-party package to load seeds/fixtures into your application: http://www.sitepoint.com/data-fixtures-symfony2/

Martin Bean
  • 38,379
  • 25
  • 128
  • 201
  • 5
    I don't think Fixtures are equal to seeds. Seeds are like to add data for your project and which is a part of project deployment. While Fixtures are used for testing or dummy data – Shadman Aug 07 '20 at 10:32
  • 2
    @Shadman Thanks for commenting on a 5 year old answer… Seeding can be used in tests to populate a database with dummy records to then test against. – Martin Bean Aug 07 '20 at 13:12
4

All the answers here are a bit outdated and this question is the first result on google so for future readers:

Since Symfony 3 there is an official bundle for this very purpose

Installation with symfony flex: composer require --dev orm-fixtures

Installation without flex: composer require --dev doctrine/doctrine-fixtures-bundle

Then write your fixtures in src/DataFixtures and run php bin/console doctrine:fixtures:load

Tofandel
  • 3,006
  • 1
  • 29
  • 48
0

Try this package https://packagist.org/packages/evotodi/seed-bundle. Looks like it's what you need.

Their readme

Symfony/Doctrine Seed Bundle Used to load/unload seed data from the database. Example would be to load a table with a list of states and abbreviations, or populate the users table with initial admin user(s). Unlike the DoctrineFixturesBundle which is mainly for development this bundle is for seeding the database before the initial push to production.

GusDeCooL
  • 5,639
  • 17
  • 68
  • 102