Class DatabaseFactoriesTasksUserFactory located in ./database/factories/tasks/UserFactory.php does not comply with psr-4 autoloading standard. Skipping.
这是我的php文件:
<?php
namespace DatabaseFactoriesTasks;
use AppModelsTasksUser;
use IlluminateDatabaseEloquentFactoriesFactory;
use IlluminateSupportStr;
class UserFactory extends Factory
{
...
}
位于:database/factories/tasks/
有人能解释一下为什么这不符合psr-4自动装载标准吗?
PSR-4自动加载标准区分大小写。因此,如果你的命名空间以大写字母开头,你的文件夹名称也应该这样做。
在您的示例中,目录应该是Database/Factorys/Tasks。
将composer.json文件中的这一行从这个
"autoload": {
"psr-4": {
"App\": "app/",
"Database\Factories\": "Database/Factories/",
"Database\Seeders\": "Database/Seeders/"
}
},
至
"autoload": {
"psr-4": {
"App\": "app/",
"Database\Factories\": "Database/Factories/Task",
"Database\Seeders\": "Database/Seeders/"
}
},