#development #laravel #pattern #php

When you use seeders to populate your database in Laravel, you sometimes have the need to run these from your code (e.g. from a command-line utility of after a certain migration happened.

It turns out this is very easy to do:

1$seeder = new UserSeeder();
2$seeder->run();

If you want to run them from the command-line, you do:

php artisan db:seed --class=UserSeeder