php Laravel Forge上的部署未找到抛出faker异常

piv4azn7  于 2022-12-10  发布在  PHP
关注(0)|答案(3)|浏览(170)

我尝试在Forge上部署laravel项目,但遇到以下异常:

Symfony\Component\Debug\Exception\FatalErrorException]  
Class 'Faker\Factory' not found

我在composer.json的require-dev中有faker引用!
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"
}

}
Forge中的部署脚本:

git pull origin master 
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan db:seed --class="StaticDataSeeder"

我能够在本地部署相同的项目,没有任何问题,Forge上的Composer更新也成功运行,我可以看到faker包被下载。
如果我遗漏了什么,请告诉我。

oxf4rvwz

oxf4rvwz1#

有一个明显的冲突可以解释你的问题:
1.您已经将"fzaninotto/faker"包添加到require-dev部分。
1.您正在运行带有--no-dev选项的deployment composer install命令,该选项明确禁止安装require-dev中列出的软件包。
因此,解决方案是将软件包移动到require部分,或者在部署时删除--no-dev选项。

j0pj023g

j0pj023g2#

我有同样的问题在heroku部署我认为它是相同的,我修复与
1.将"fzaninotto/faker": "~1.4""require-dev"移动到composer.json中的"require",并锁定编写器

  1. composer安装
    1.编写器更新
  2. git加法器
  3. git提交
  4. git推动heroku
    如果不使用heroku作为部署,则不要从步骤4-6开始运行
mfuanj7w

mfuanj7w3#

运行下一个命令:

composer install

问题应该会消失

相关问题