简体   繁体   English

PHP在Heroku上部署-推送失败

[英]PHP deploy on heroku - push failed

I have been trying to deploy a php app on heroku but I keep getting this error: 我一直在尝试在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

anyone know how I can solve it? 有人知道我该怎么解决吗?

So this is what I would look at, and sorry if any of these assumptions are wrong, or I am going through stuff you have already done. 所以这就是我要看的,如果这些假设中的任何一个错误,或者我正在研究您已经做的事情,则对不起。

  1. Your composer.json should be divided up into require and require-dev. 您的composer.json应该分为require和require-dev。 Require would be installed in production with require-dev added locally. 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. If you have not got composer installed you need to do so. 如果尚未安装作曲家,则需要这样做。 https://www.hostinger.com/tutorials/how-to-install-composer https://www.hostinger.com/tutorials/how-to-install-composer

  2. Run php composer install in the first instance of php composer update later on to install your dependencies. 稍后在php composer update的第一个实例中运行php composer install来安装依赖项。

  3. Please commit everything except, the vendor files and any cache or logging. 请提交所有内容,除了供应商文件和所有缓存或日志记录。 This would include composer.lock which is a list of installed dependencies and the versions you are using. 这将包括composer.lock,它是已安装的依赖项和您使用的版本的列表。

  4. Heroku will install these dependencies in production making sure it uses the same version as specified in the lock file. Heroku将在生产环境中安装这些依赖项,以确保其使用与锁定文件中指定的版本相同的版本。

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

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