Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jelore's avatar

Seeder class not found in Laravel5 Seeding

I follow the docs: http://laravel.com/docs/master/migrations#database-seeding

I placed some seeders class In database/seeds/ folder, My DatabaseSeeder class now looks like this :

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class DatabaseSeeder extends Seeder {

    public function run()
    {
        Model::unguard();

        $this->call('SectorsTableSeeder');
        $this->call('JobsTableSeeder');
        $this->call('SmicTableSeeder');
    }
}

but when I run it I got an error

[Symfony\Component\Debug\Exception\FatalErrorException]  
Class 'Seeder' not found

Even if I run "composer dump-autoload" or "php artisan optimize" I still got this error.

I don't know what to do to force Seeder class to be loaded.

Can someone help me please?

0 likes
10 replies
bingvanmoorsel's avatar

How do your seeders look like ? It seems like your trying to fill a Seeder Model. I guess thats not what your planning to do?

bashy's avatar
bashy
Best Answer
Level 65

Have you got this at the top in each seeder file?

use Illuminate\Database\Seeder;
jelore's avatar

Sorry. I am such an Idiot. I was so sure that the error comme from DatabaseSeeder, that i forget to really check my seeders. I didn't import Seeder class in seeders. Thank you all for your answers.

falak_hamid's avatar

I create my new seeder classes when i seed these classes using command php artisan db:seed i got an error that is

[ReflectionException] Class BookingDates(my seeding class name) not found Plz tell me how i remove this error

davorminchorov's avatar

@falak_hamid You have to run:

composer dump-autoload -o 

for the autoloader to pick up the newly classes because the database folder is not automatically autoloaded with PSR-4.

26 likes
bidhu's avatar

I used "use Illuminate\Database\Seeder;" in all the seeder files. And I call all the classes from inside the DatabaseSeeder class as

public function run() {

$this->call(AuthorsTableSeeder :: class);

}

It works fine for me now.

1 like
Randy_Johnson's avatar

I had an error with the seeder, I fixed all the classes and re ran the command to find the error again. I then ran this:

composer dumpautoload

and everything was working fine. What is this command doing?

Please or to participate in this conversation.