An Error: ReflectionException of the Class CountrySeeder does not exist in Laravel PHP.

Why does this error occur? (ReflectionException : Class CountrySeeder does not exist)

Mainly for two reasons:

First Reason:– Either, we haven’t created seeder file.

Table of Contents

Solution

Step 1. So, Create seeder file by this following command:-

php artisan make:seeder CountriesTableSeeder

Step 2. Now, Run the Seeder class individually into database

php artisan db:seed --class=CountrySeeder

Second Reason:- Or, we haven’t added the seeder file into the database/seeds/DatabaseSeeder.php file.

Solution

Step 1. Add this within the run function.

$this->call(CountriesTableSeeder::class);
 public function run()
    {
        $this->call(UsersTableSeeder::class);
	$this->call(RolesTableSeeder::class);
        $this->call(CountriesTableSeeder::class);
        $this->call(StatesTableSeeder::class);
       
    }

Thanks