Categories
Laravel

Laravel 8 Target class [TableSeeder] does not exist

Today I am getting this error when I am trying to refresh seed with php artisan migrate:refresh –seed command. Database Seeder class is called another seeder class with $this->call(CmsPagesSeeder::class); But geeting error Target class [CmsPagesSeeder] does not exist.

Finally I have apply follwing solution and now working fine with command php artisan migrate:refresh –seed or php artisan db:seed or php artisan db:seed –class=CmsPagesSeeder

Laravel 8 Seeders and Factories are now need to add namespace at the top of class file.

Example:

STEP: 1

Rename directory database/seeds to database/seeders

STEP: 2

Open composer.json file and change on autoload section.

STEP: 3

Open Database Seeder file database/seeders/DatabaseSeeder.php and add namespace Database\Seeders; on top of page.

STEP: 4

Open your others seeders file and add namespace Database\Seeders; to all seeders class.

STEP: 5
Done! Now run following commands you can see now DB seeder is working fine.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please LIKE and SHARE

Related Articles