gpt4 book ai didi

php - 错误 [RuntimeException] 无法扫描 "database/seeds"内的类

转载 作者:行者123 更新时间:2023-12-02 16:08:09 32 4
gpt4 key购买 nike

我在运行 composer update 时遇到问题

同样的事情也发生在其他安装命令上

错误:

[RuntimeException] Could not scan for classes inside"database/seeds" which does not appear to be a file nor a folder

如何解决这个错误?尝试,运行 composer install,它也不起作用

{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}

最佳答案

将 Composer 自动加载更改为

"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
}

在 Laravel 8 中,两个目录 Factory 和 seeders 都有命名空间。在 Laravel 7 中,它仍然使用类映射来加载它们。

首先,检查你的类是否使用命名空间,然后使用 psr4 自动加载,否则你可以使用类映射;

关于php - 错误 [RuntimeException] 无法扫描 "database/seeds"内的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68779576/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com