Laravel seeds error ReflectionException “Class does not exist error”

When I ran the following artisan seed command, I received an error:

php artisan db:seed

I kept receiving the following error:

[ReflectionException]
Class XTableSeeder does not exist

This command helped fix the error:

composer dump-autoload

Also check that you have a Seeder file in /database/seeds/

eg XTableSeeder.php

With content similar to this

<?php

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

class RoleTableSeeder extends Seeder {

public function run() {
DB::table(‘x’)->delete();
DB::table(‘x’)->insert([

]);

}

And make sure you have added the call in the DatabaseSeeder.php file:

$this->call(‘XTableSeeder’);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.