从5.7数据库升级到6.0数据库后的流明:种子命令不起作用



我已经从Lumen 5.7升级到6.0。升级后,artisan db:seeder命令不起作用。显示Target class [DatabaseSeeder] does not exist。我试过运行composer dump-autoload,但它没有解决问题。下面是composer.json文件

{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": [
"framework",
"laravel",
"lumen"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.1.3",
"guzzlehttp/guzzle": "^7.2",
"laravel/lumen-framework": "^6.0",
"vlucas/phpdotenv": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "~7.0",
"mockery/mockery": "~1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": []
},
"scripts": {
"post-root-package-install": [
"@php -r "file_exists('.env') || copy('.env.example', '.env');""
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"allow-plugins": {
"kylekatarnls/update-helper": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

请帮助

Laravel更改了seeders类的目录(从数据库/种子到数据库/种子(,因此您可能需要以这种方式更新您的composer.json(在autoload/psr-4中移动种子(:

"autoload": {
"psr-4": {
"App\": "app/",
"Database\Factories\": "database/factories/",
"Database\Seeders\": "database/seeders/"
},
"files": [
"app/helpers/helpers.php"
]
},

并将命名空间添加到种子文件中:

<?php

namespace DatabaseSeeders;

use IlluminateDatabaseSeeder;

class DatabaseSeeder extends Seeder
{
....

不要忘记在更新文件后运行composter dump-autoload

相关内容

  • 没有找到相关文章

最新更新