简体   繁体   中英

Class ArticlesTableSeeder does not exist, but ArticlesTableSeeder exists

I have created a project using Laravel 5.4 and Homestead. I created a seed using php artisan make:seeder ArticlesTableSeeder , which results in a 'seeder created successfully' message. The seeder is in database/seeds/ ArticlesTableSeeder.php and looks like this:

<?php

use Illuminate\Database\Seeder;

class ArticlesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Article::truncate();

        $faker = \Faker\Factory::create();

        for($i = 0; $i < 50; $i++) {
            Article::create([
                'title' => $faker->sentence,
                'body' => $faker->paragraph,
            ]);
        }
    }
}

However, when I run php artisan db:seed --class=ArticlesTableSeeder I get this error:

[ReflectionException]                     
Class ArticlesTableSeeder does not exist

What's going on here?

在使用新创建的播种机类之前,您需要运行composer du命令。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM