tommus/sprout

Grow your Laravel seeders.

1.0.1 2019-02-05 14:16 UTC

This package is auto-updated.

Last update: 2025-06-06 12:15:49 UTC


README

Grow your Laravel seeders.

Sprout allows you to write more modular, reuseable seeders for specific scenarios in your app.

For example, creating a "full event" by creating an event and ten bookings. Or, creating an "empty event" by creating just an event.

Usage

  1. Pull in the package with composer:
composer require tommus/sprout

Laravel will automatically discover the Sprout Service Provider, meaning you don't need to manually add it.

  1. Publish the Sprout vendor files:
php artisan vendor:publish --tag=sprout
  1. Create a new Sprout:
php artisan sprout:make Example

This will make a new Sprout at App/Sprouts/Example.php. In the run() method, you can add any factories or calls you'd like.

You can call another Sprout by using $this->call(Sprout::class) from within the called Sprout. This happens recursively.

Optionally, you can add a beforeRun() and afterRun() method to a Sprout to build up and tear down specific config.

You can add a protected $description = 'Custom Title'; to a Sprout.

  1. Add the Sprout to config/sprout.php:
return [
  'list' => [
    \App\Sprouts\Example::class,
  ],
];
  1. Run the Sprout:
php artisan sprout:run

This allows you to choose a Sprout to run from the list defined in the Sprout config.