我正在使用Symfony和fzaninotto / faker库
我正在使用该库来测试一些东西,但是在运行phpunit时出现此错误:
错误:找不到“ Faker \ Factory”类
和往常一样,我使用的是正确的use Faker\Factory;
如您所见,仅在我的开发中是必需的,并且我运行composer install
composer.json
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
...
"symfony/framework-bundle": "4.1.*",
},
"require-dev": {
"fzaninotto/faker": "^1.8",
"symfony/dotenv": "4.1.*",
"symfony/test-pack": "^1.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.1.*"
}
}
}
答案 0 :(得分:0)
可能我的解决方案不是最好的,但是不是推荐的软件包“使用Symfony的桥:作曲家需要--dev phpunit”
我决定安装通常的“ composer require --dev phpunit / phpunit ^ 6.5”
然后一切都按预期进行。