在heroku上部署PHP - 推送失败

时间:2018-03-25 02:33:56

标签: php git heroku composer-php

我一直在尝试在heroku上部署一个php应用程序,但我一直收到这个错误:

-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
       ERROR: neither your composer.json 'require' section nor any
       dependency therein requires a runtime version, but 'require-dev'
       or a dependency therein does. Heroku cannot automatically select
       a default runtime version in this case.
       Please add a version requirement for 'php' to section 'require'
       in composer.json, 'composer update', commit, and deploy again.
 !     ERROR: Couldn't load 'composer.lock'; it must be a valid lock
       file generated by Composer and be in a consistent state.
       Check above for any parse errors and address them if necessary.
       Run 'composer update', add/commit the change, then push again.
 !     Push rejected, failed to compile PHP app.
 !     Push failed

任何人都知道如何解决它?

1 个答案:

答案 0 :(得分:0)

所以这就是我要看的,如果这些假设中的任何一个是错误的,或者我正在处理你已经完成的事情,那就很抱歉。

  1. 你的composer.json应该分为require和require-dev。需要将安装在生产中,并在本地添加require-dev。
  2. { "name": "something/something", "description": "A description of my project", "type": "project", "require": { "php": ">=5.5.9", "doctrine/cache": "1.4.*", "elasticsearch/elasticsearch": "~2.0", "monolog/monolog": "~1.0", "knplabs/github-api": "~1.2", "ezyang/htmlpurifier": "~4.6", "easyrdf/easyrdf": "0.9.*", "hoa/compiler": "~2.15", "hoa/visitor": "~1.15", "collectiveaccess/service-wrapper": "v1.1", "phpoffice/phppresentation": "dev-master", "phpoffice/phpword": "v0.13.*" }, "require-dev": { "phpunit/phpunit": "4.3.*", "maximebf/debugbar": ">=1.0.0" } }

    1. 如果您没有安装作曲家,则需要这样做。 https://www.hostinger.com/tutorials/how-to-install-composer

    2. 稍后在php composer install的第一个实例中运行php composer update以安装您的依赖项。

    3. 请提交除供应商文件和任何缓存或日志记录之外的所有内容。这将包括composer.lock,它是已安装的依赖项列表以及您正在使用的版本。

    4. Heroku将在生产中安装这些依赖项,确保它使用与锁定文件中指定的版本相同的版本。