在 Laravel Forge 上部署抛出 faker 未找到异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32801183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Deployment on Laravel Forge throwing faker not found Exception
提问by vthallam
I am trying to deploy a laravel project on forge and i am getting the below exception :
我正在尝试在 Forge 上部署 Laravel 项目,但出现以下异常:
Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Faker\Factory' not found
I have the faker reference in require-dev in composer.json!
我在 composer.json 中的 require-dev 中有 faker 参考!
composer.json file
composer.json 文件
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"tymon/jwt-auth": "0.5.*",
"dingo/api": "1.0.x@dev"
},
"require-dev": {
"fzaninotto/faker": "~1.5",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"laracasts/testdummy": "1.*",
"laracasts/generators": "^1.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
}
Deployment script in Forge:
Forge 中的部署脚本:
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan db:seed --class="StaticDataSeeder"
I was able to deploy the same project locally with out any problem and composer update on forge also runs successfully and i can see the faker package getting downloaded.
我能够在本地部署相同的项目而没有任何问题,并且 forge 上的 composer update 也成功运行,我可以看到 faker 包正在下载。
Please let me know if i am missing something.
如果我遗漏了什么,请告诉我。
回答by Bogdan
There is a clear conflict that explains your problem:
有一个明显的冲突可以解释您的问题:
You've added the
"fzaninotto/faker"
package to therequire-dev
section.You're running the deployment
composer install
command with the--no-dev
option which explicitly prohibitsinstalling the packages listed inrequire-dev
.
您已将
"fzaninotto/faker"
包添加到该require-dev
部分。您正在运行
composer install
带有明确禁止安装 中列出的软件包的--no-dev
选项的部署命令。require-dev
So the solution is either to move the package to the require
section or remove the --no-dev
option when deploying.
所以解决方案要么是将包移动到该require
部分,要么--no-dev
在部署时删除该选项。