Laravel Packages / February 03, 2015

Laravel SmartSeeder

SmartSeeder is a new Laravel package by Jordan Lapp, that is designed to handle database seeding the same way you handle migrations.

Seeding as it is currently done in Laravel is intended only for dev builds, but what if you want to seed a production database with different data from what you use in development? What if you want to seed a table you’ve added to a database that is currently in production with new data?

The package isn’t just for seeding production databases. You can seed debug databases in batches, just like migrations. Compared to the default Laravel seeding, where all seeds have to be run at the same.

The features of the package include:

  • Allows you to seed databases in different environments with different values.
  • Allows you to “version” seeds the same way that Laravel currently handles migrations. Running php artisan seed will only run seeds that haven’t already been run.
  • Prompts you if your database is in production.
  • Allows you to run multiple seeds of the same model/table
  • Overrides Laravel’s seeding commands. SmartSeeder will fire when you run php artisan db:seed or php artisan migrate:refresh --seed

I can see a few good use cases for this system and it would come in handy on an app I’m currently building. I already know that one table is going to need additional seed data added a year or so down the road.

Laravel News Partners


Join the weekly newsletter and never miss out on new tips, tutorials, and more.