简体   繁体   中英

PHP deploy on heroku - push failed

I have been trying to deploy a php app on heroku but I keep getting this error:

-----> 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. Require would be installed in production with require-dev added locally.

{ "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

  2. Run php composer install in the first instance of php composer update later on to install your dependencies.

  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.

  4. Heroku will install these dependencies in production making sure it uses the same version as specified in the lock file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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