数据库播种器找不到 class 和 Laravel 5.2

Database Seeder cannot find class with Laravel 5.2

运行宁php artisan migrate --seed时出现这个错误:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'CreateCharactersTable' not found. 

这是 class:

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class CharacterSeeder extends Seeder
{
    public function run()
    {
        DB::table('characters')->delete();

        DB::table('characters')->insert([
            'user_id'   => 999,
            'name'      => 'Susan Strong',
            'race'      => 'orc',
            'class'     => 'assassin',
            'image_location'    => null,
            'combat_level'      => '0',
            'base_str'  => 6,
            'base_int'  => 4,
            'base_apt'  => 5,
            'mod_str'   => 9,
            'mod_int'   => 5,
            'mod_apt'   => 7,
            'xp_str'    => 1,
            'xp_int'    => 2,
            'xp_apt'    => 1,
            'is_bot'    => 1,
            'created_at'=> '2017-04-02 17:53:02',
            'updated_at'=> '2017-04-02 17:53:02'
        ]);



        DB::table('characters')->insert([
            'user_id'   => 4,
            'name'      => 'Chale',
            'race'      => 'elf',
            'class'     => 'scholar',
            'image_location'    => null,
            'combat_level'      => '0',
            'base_str'  => 3,
            'base_int'  => 7,
            'base_apt'  => 5,
            'mod_str'   => 6,
            'mod_int'   => 10,
            'mod_apt'   => 6,
            'xp_str'    => 1,
            'xp_int'    => 2,
            'xp_apt'    => 1,
            'is_bot'    => 1,
            'created_at'=> '2017-04-02 17:53:02',
            'updated_at'=> '2017-04-02 17:53:
    }
}

?>

和播种机:

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Database\Seeds\CharacterSeeder;
use Database\Seeds\ClassesTableSeeder;
use Database\Seeds\RacesTableSeeder;
use Database\Seeds\UserTableSeeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(UserTableSeeder::class);
        $this->call(CharacterSeeder::class);
        $this->call(RacesTableSeeder::class);
        $this->call(ClassesTableSeeder::class);
    }
}

运行 composer dumpautoload 通过但没有消除错误。当它只有两个播种机时,User 和 Character,它 运行 很好。尽管一遍又一遍地查看新的播种机,但我无法确定所涉及的错误。

有什么建议可以让播种机到达 运行?

谢谢。

您已经从命名空间导入了所有播种机,但它们不在命名空间中。

use Database\Seeds\CharacterSeeder;
use Database\Seeds\ClassesTableSeeder;
use Database\Seeds\RacesTableSeeder;
use Database\Seeds\UserTableSeeder;

只需删除这些行,您就可以开始了。

Class'CreateCharactersTable'应该是Migration。您需要检查此迁移文件或 class 是否存在。

如果您只使用播种机。你可以执行 php artisan db:seed

如果您手动添加了种子文件,您应该首先 运行 composer dump-autoload。这将为您重新生成 autoload_classmap.php 文件,有关详细信息,请参阅 Composer Dump-Autoload