Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 目标类[DatabaseSeeder]不存在_Php_Laravel_Laravel 8_Laravel Seeding - Fatal编程技术网

Php 目标类[DatabaseSeeder]不存在

Php 目标类[DatabaseSeeder]不存在,php,laravel,laravel-8,laravel-seeding,Php,Laravel,Laravel 8,Laravel Seeding,当我运行php artisan migrate:fresh-seed时 我得到一个错误: 目标类[DatabaseSeeder]不存在 我做了这个链接中指出的建议,但没有影响相同的问题 这是我的databaseseeder,在/database/seeders中/ <?php namespace Database\Seeders; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder { /**

当我运行php artisan migrate:fresh-seed时 我得到一个错误:

目标类[DatabaseSeeder]不存在

我做了这个链接中指出的建议,但没有影响相同的问题

这是我的databaseseeder,在/database/seeders中/

<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $this->call(UsersSeeder::class);
        $this->call(InstallationSeeder::class);
        $this->call(MaintenanceReasonSeeder::class);
        $this->call(CompanytypesSeeder::class);
        $this->call(LocationTypeSeeder::class);
        $this->call(formTypeseeder::class);
    }
}

您需要从类映射中删除条目,并在psr4下指定数据库名称空间的映射

{ 自动加载:{ psr-4:{ App\\\:App/, 数据库\\Factories\\:数据库/工厂/, 数据库\\播种机\\:数据库/播种机/ }, 档案:[ app/helpers.php ] }, }
然后运行composer dump autoload

设置数据库\\:Database/@Tpojka就足够了。。你是对的-在将类映射条目移动到psr4时完全错过了-只是移动了两个条目并更新了-愚蠢的我。谢谢你的指点,我会更新答案的,不过还是按你的方式做吧。原因有二:Factorys和seeders目录是小写的,不遵循PSR语法,加上migrations目录由不是文件名类名等价物的类组成。嗯……这就是为什么标准Laravel 8在psr4下为Factorys和seeders有两个不同的映射名称空间的条目。让我再更新一次。
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $this->call(UsersSeeder::class);
        $this->call(InstallationSeeder::class);
        $this->call(MaintenanceReasonSeeder::class);
        $this->call(CompanytypesSeeder::class);
        $this->call(LocationTypeSeeder::class);
        $this->call(formTypeseeder::class);
    }
}