What is a Seeder in Laravel?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Laravel development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

Seeders populate your database with test or initial data. Generate: php artisan make:seeder UserSeeder. The seeder's run() method contains the database insert logic. Run a specific seeder: php artisan db:seed --class=UserSeeder. Run all seeders registered in DatabaseSeeder: php artisan db:seed. Combine with factories: User::factory()->count(50)->create(). Seeders are useful for: populating initial data (admin users, categories, settings), creating test data for development, and resetting the database to a known state. Use php artisan migrate:fresh --seed to rebuild and reseed from scratch.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last Laravel project, I used this when...' immediately makes your answer more credible and memorable.