Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a REST API with Laravel Seeding the Database Factories and Seeders

Caitlin Scouler
Caitlin Scouler
7,082 Points

Illuminate\Contracts\Container\BindingResolutionException

Hi guys,

I got all the way to the end of the video and attempted to update the Laravel to v8 but hitting an error when I try to seed,

'Target class [Database\Seeders\NamedTableSeeder] does not exist.'

It says it is at line 875:

'framework\src\Illuminate\Container\Container.php:875' but I have not touched this file,

Is there something I have done obviously wrong?

Many thanks,

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Caitlin Scouler! Unfortunately, the "Faker" library has been retired by the original developer. I imagine that's the issue that you're running into. It will work with older versions of Laravel and the like, but not more recent versions. It is the library that is responsible for creating the fake data to be added to the database. You can check out this blog article.

Honestly, I would consider reverting back to version 6 of Laravel as it is the latest LTS version.

Hope this helps! :sparkles:

Hello, I am currently using v6, however, I also receive this same error.

Illuminate\Contracts\Container\BindingResolutionException : Target class [BooksTableSeeder] does not exist. laravel_rest_api\vendor\laravel\framework\src\Illuminate\Container\Container.php:805

801| 
802|         try {
803|             $reflector = new ReflectionClass($concrete);
804|         } catch (ReflectionException $e) {
805|             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
806|         }
807| 
808|         // If the type is not instantiable, the developer is attempting to resolve
809|         // an abstract type such as an Interface or Abstract Class and there is

Exception trace:

1 ReflectionException::("Class BooksTableSeeder does not exist") laravel_rest_api\vendor\laravel\framework\src\Illuminate\Container\Container.php:803

2 ReflectionClass::__construct("BooksTableSeeder") laravel_rest_api\vendor\laravel\framework\src\Illuminate\Container\Container.php:803

Found the solution. https://laravel.com/docs/6.x/seeding#running-seeders

Once you have written your seeder, you may need to regenerate Composer's autoloader using the dump-autoload command:

composer dump-autoload