简体   繁体   English

Heroku 部署:'composer install' 过程因错误而失败

[英]Heroku Deployment: The 'composer install' process failed with an error

I try to deploy my project to Heroku using the following command:我尝试使用以下命令将我的项目部署到 Heroku:

git push heroku master

Although it was working fine before now it gives me these errors:虽然它之前工作正常,但它给了我这些错误:

remote:  !     WARNING: There was a class not found error in your code
remote: 
remote:  !     ERROR: Dependency installation failed!
remote:  !     
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !     
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !     
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !     
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:  !     
remote:  !     REMINDER: the following warnings were emitted during the build;
remote:  !     check the details above, as they may be related to this error:
remote:  !     - Your 'composer.lock' is out of date!
remote:  !     - There was a class not found error in your code
remote: 
remote:  !     Push rejected, failed to compile PHP app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to radiant-forest-10738.
remote: 
To https://git.heroku.com/radiant-forest-10738.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/radiant-forest-10738.git'

here is composer.json file:这是 composer.json 文件:

{
    "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"
    },
    "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"
        ]
    }
}

I have tried all the instructions and implemented these commands in terminal:我已经尝试了所有说明并在终端中实现了这些命令:

composer update git add composer.json composer.lock作曲家更新 git 添加 composer.json composer.lock

I do know where is the error from because I have tried many solutions even deleting what`s inside post-create-project-cmd.我确实知道错误来自哪里,因为我尝试了很多解决方案,甚至删除了 post-create-project-cmd 中的内容。

If anyone could help me with this I would appreciate it如果有人可以帮助我,我将不胜感激

I have encountered this issue.我遇到过这个问题。 Try removing all files on the heroku bash尝试删除 heroku bash 上的所有文件

Steps脚步

  1. heroku run bash
  2. ~$: rm -rf.*
  3. ~$: rm -rf *

Reclone (force)重新克隆(强制)

  1. git push heroku master -f

If It says its updated, then you can just clone normally ~$: heroku git:clone -a <insert app name>如果它说它已更新,那么您可以正常克隆~$: heroku git:clone -a <insert app name>

just run heroku restart只需运行heroku restart

your heroku bash get stuck and the server need to restart你的 heroku bash 卡住了,服务器需要重启

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM