繁体   English   中英

PHP在Heroku上部署-推送失败

[英]PHP deploy on heroku - push failed

我一直在尝试在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. 您的composer.json应该分为require和require-dev。 Require将安装在生产环境中,并在本地添加require-dev。

{ "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 update的第一个实例中运行php composer install来安装依赖项。

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

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

暂无
暂无

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

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