将响应CMS推送到Heroku:没有找到'composer.lock'

ber*_*ben 0 git heroku composer-php respondcms

我想在Heroku上托管Respond CMS,所以我做了:

  1. git clone 响应存储库的
  2. heroku 在该文件夹中创建
  3. git push heroku master

我总是在终端中收到以下错误:

remote: ----->PHP app detected
remote:
remote:  !     ERROR: Your 'composer.json' lists dependencies inside 'require',
remote:        but no 'composer.lock' was found. Please run 'composer update' to
remote:        re-generate 'composer.lock' if necessary, and commit it into your
remote:        repository. For more information, please refer to the docs at
remote:        https://devcenter.heroku.com/articles/php-support#activation
remote:
remote:
remote:  !     Push rejected, failed to compile PHP app
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to app-name
Run Code Online (Sandbox Code Playgroud)

我跑了composer update,工作正常,composer.lock文件夹中也有一个文件.

为什么这不起作用?

Chr*_*ris 5

composer.lock文件不仅必须在本地存在,还必须提交.这样,当你推送到Heroku时它将被包括在内.

尝试这样的事情:

  • git add composer.lock
  • git commit 使用像这样的消息 Add Composer lock file
  • git push heroku (或者你的遥控器叫什么)

这样做的原因composer.json通常是以某种模糊的方式指定依赖关系,例如"无论最新的1.2.x版本是什么"还是"最新的master分支提交".您可以想象,根据我们安装依赖项的时间,您和我可能会得到不同的结果.

composer.lock文件的工作是以更严格的方式锁定这些依赖项.如果您安装了库的最新1.2.x版本,则会记录其精确版本composer.lock,例如"版本1.2.2 at Git hash 1234abc".

一般情况下,除非您故意更新库,否则最好使用composerinstall,而不是composer update.前者使用锁定文件中的确切版本,不会更新任何内容.这样我们就可以更自信地使用相同的库.后者更新新版本并更改锁定文件.

我从来没有将Heroku与PHP一起使用,但有意义的是它要安装锁定文件中列出的确切版本.