I am trying to run php artisan db:seed
but getting this error same running this command php artisan db:seed --class=PersonTableSeeder:
Target class [PersonTableSeeder] does not exist.
database/seeders/DatabaseSeeder.php:14
Illuminate\Database\Seeder::call("PersonTableSeeder")
+24 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
P.S Everybody says to run composer dump-autoload but it doesn't help me to solve this issue.
I also tried these commands with no result:
php artisan optimize
php artisan clear:cache
composer clearcache
composer dump-autoload
Also I made sure that both DatabaseSeeder and PersonTableSeeder files are in the same folder
This is my code:
DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call(PersonTableSeeder::class);
}
}
PersonTableSeeder:
<?php
use Illuminate\Database\Seeder;
use App\Person;
class PersonTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(Person::class, 50)->create();
}
}
PersonFactory:
<?php
use Faker\Generator as Faker;
$factory->define(App\Person::class, function (Faker $faker) {
return [
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'email' => $faker->safeEmail,
'phone' => $faker->phoneNumber,
'city' => $faker->city,
];
});
for those who land on this page still looking for an answer, if you run
composer dump-autoload it'll solve your issue!
it's simple, just do a
composer dump-autoload
it worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With