我正在尝试播种“ DatabaseSeeder.php”,但是当我尝试运行时
import random
first_data = ['S1',0,100]
X = ['','','','','','','','','']
Y = ['','','','','','','','','']
coordinates = ()
class SeriesGenerator:
def generate_random(self):
minV = first_signal[1]
maxV = first_signal[2]
for i in range(9):
X[i] = minV+(maxV-minV)*random.random()
Y[i] = minV+(maxV-minV)*random.random()
return X,Y
def create_axes(self):
for e in Y:
for u in X:
coordinates(u,e)
print(coordinates)
SeriesGenerator().create_axes()
我收到错误消息:
目标类[DatabaseSeeder]不存在。
我在“ DatabaseSeeder.php”中的代码如下:
php artisan db:seed
到目前为止我尝试过的事情:
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
factory(App\User::class, 3)->create()->each(function($u) {
$u->questions()
->saveMany(
factory(App\Question::class, rand(1, 5))->make()
);
});
}
}
composer dump-autoload
php artisan cache:clear
注意:我没有用户制作的播种器,我试图使用默认的播种器(DatabaseSeeder.php),但是由于某种原因,它告诉我它不存在。 / strong>
答案 0 :(得分:1)
在 Laravel 7 中,composer.json 需要在自动加载映射中引用 classmap,因为默认种子文件夹不遵守 PSR-4:database/seeds
(参见 Laravel Documentation - Database: Seeding)
检查以在 composer.json 中包含此内容:
"classmap": [
"database/seeds",
"database/factories"
],
然后运行 composer dump-autoload
看到这个类似的错误:Target class [DatabaseSeeder] does not exist - Laravel 7 and Composer 2