I added a seeder (copied from elsewhere and pasted) to my application and included the call in the Database Seeder run() function. I get the exception above even though the class exists.
I suspected that maybe some files may have been cached so i cleared the application cache but i still get the same error.
DatabaseSeeder.php
<?php use IlluminateDatabaseSeeder; class DatabaseSeeder extends Seeder { /** * Seed the application's database. * * @return void */ public function run() { // $this->call(CustomersTableSeeder::class); $this->call(RolesTableSeeder::class); $this->call(ManagerStatesTableSeeder::class); $this->call(ManagersTableSeeder::class); $this->call(CountsTableSeeder::class); $this->call(CategoriesTableSeeder::class); } }
Seeder file CategoriesTableSeeder.php
<?php use IlluminateDatabaseSeeder; class CategoriesTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { DB::table('categories')->insert([ [ 'description' => 'Perfumes and Deo', 'slug' => 'perfumes-and-deo', 'parent' => 0, 'level' => 1, 'cna' => '2|', 'created_at' => CarbonCarbon::now(), 'updated_at' => CarbonCarbon::now(), ], [ 'description' => 'Perfumes', 'slug' => 'perfumes', 'parent' => 1, 'level' => 2, 'cna' => NULL, 'created_at' => CarbonCarbon::now(), 'updated_at' => CarbonCarbon::now(), ] ]); } }
Error:
ReflectionException : Class CategoriesTableSeeder does not exist
at C:wampwwwma-sales-trackervendorlaravelframeworksrcIlluminateContainerContainer.php:788
Exception trace:
1 ReflectionClass::__construct(“CategoriesTableSeeder”) C:wampwwwma-sales-trackervendorlaravelframeworksrcIlluminateContainerContainer.php:788
2 IlluminateContainerContainer::build(“CategoriesTableSeeder”) C:wampwwwma-sales-trackervendorlaravelframeworksrcIlluminateContainerContainer.php:667
Any ideas on what might be causing this? Thanks in advance guys
Advertisement
Answer
I run Composer dump-autoload and voila! Worked as a charm. Also as suggested by Alex Mac, always generate Seeders with artisan commands.