我想在Heroku上托管Respond CMS,所以我做了:
git clone
的respondcms存储库heroku
在该文件夹中创建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
我运行了composer update
,工作正常,文件夹中还有一个composer.lock
文件。
为什么这不起作用?
答案 0 :(得分: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在Git hash 1234abc"。
一般情况下,除非您故意更新库,否则最好使用composer
install
,而不是composer update
。前者使用锁定文件中的确切版本,并且不会更新任何内容。这样我们就可以更自信地使用相同的库。后者更新新版本并更改锁定文件。
我从未将Heroku与PHP一起使用,但有意义的是它要安装锁定文件中列出的确切版本。