Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
752 views
in Technique[技术] by (71.8m points)

php - in laravel 8 with seeding , i has this issue Target class [TableSeeder] does not exist

IlluminateContractsContainerBindingResolutionException

  Target class [DatabaseSeedersCountriesTableSeeder] does not exist.

  at C:......logvendorlaravelframeworksrcIlluminateContainerContainer.php:811
    807▕
    808▕         try {
    809▕             $reflector = new ReflectionClass($concrete);
    810▕         } catch (ReflectionException $e) {
  ? 811▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    812▕         }
    813▕
    814▕         // If the type is not instantiable, the developer is attempting to resolve
    815▕         // an abstract type such as an Interface or Abstract Class and there is

  1   C:......logvendorlaravelframeworksrcIlluminateContainerContainer.php:809
      ReflectionException::("Class DatabaseSeedersCountriesTableSeeder does not exist")

  2   C:......logvendorlaravelframeworksrcIlluminateContainerContainer.php:809
      ReflectionClass::__construct("DatabaseSeedersCountriesTableSeeder")
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From laravel 8 Seeders and factories are now namespaced


To accommodate for these changes, add DatabaseSeeders namespace to your seeder classes.

namespace DatabaseSeeders;

In addition, move all seeder files from previous database/seeds directory to database/seeders folder.


In your case remove all lines started with use DatabaseSeeders...
from DatabaseSeeder.php file

It should solve the issue,

You can also run dump-autoload & fresh migration with seed,

composer dump-autoload

php artisan migrate:fresh --seed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...