Rumah > pembangunan bahagian belakang > tutorial php > 请问在coding如何通过composer.json安装自定义包,来部署PHP环境?

请问在coding如何通过composer.json安装自定义包,来部署PHP环境?

WBOY
Lepaskan: 2016-06-06 20:38:09
asal
1180 orang telah melayarinya

参考文档:http://docs.coding.io/languages/php

官方通过composer.json来配置PHP环境,例如:

<code>{
    "require": {"php": "5.5.16"}
}
</code>
Salin selepas log masuk
Salin selepas log masuk

OK,这个没有问题,我也部署成功了。现在我要使用一个第三方开发包:https://packagist.org/packages/levi/lv,修改composer.json如下:

<code>{
    "require" : {
        "php": "5.6.3",
        "levi/lv" : "dev-master",
        "ext-redis" : "*"
    }
}
</code>
Salin selepas log masuk
Salin selepas log masuk

就部署不成功了,错误提示如下:

<code>2015-02-08T18:20:55.67+0800 [API]     OUT Updated app with guid d645cb8f-2ec6-404f-89e7-0795b8ede261 ({"state"=>"STOPPED"})
2015-02-08T18:22:23.10+0800 [DEA]     OUT Got staging request for app with id d645cb8f-2ec6-404f-89e7-0795b8ede261
2015-02-08T18:20:57.88+0800 [API]     OUT Updated app with guid d645cb8f-2ec6-404f-89e7-0795b8ede261 ({"state"=>"STARTED"})
2015-02-08T18:22:25.12+0800 [STG]     OUT -----> Downloaded app package (8.0K)
2015-02-08T18:22:25.31+0800 [STG]     OUT -------> Buildpack version 1.0.2
2015-02-08T18:22:25.48+0800 [STG]     OUT  !     ERROR:        Your composer.json specifies dependencies, but no composer.lock
2015-02-08T18:22:25.48+0800 [STG]     OUT        was found, please check it into your repository along with composer.json!
2015-02-08T18:22:25.48+0800 [STG]     OUT Staging failed: Buildpack compilation step failed
2015-02-08T18:20:58.56+0800 [API]     ERR Encountered error: Staging error: failed to stage application:
2015-02-08T18:20:58.56+0800 [API]     ERR Script exited with status 1
</code>
Salin selepas log masuk
Salin selepas log masuk

我看官方文档有段说明是这样的:

构建

系统会运行以下命令来解决依赖:

<code>install --no-dev --prefer-dist --optimize-autoloader --no-interaction
</code>
Salin selepas log masuk
Salin selepas log masuk

好像是在部署的时候,默认就不执行安装开发包,那么请问如何在coding中安装一个第三方开发包呢?

回复内容:

参考文档:http://docs.coding.io/languages/php

官方通过composer.json来配置PHP环境,例如:

<code>{
    "require": {"php": "5.5.16"}
}
</code>
Salin selepas log masuk
Salin selepas log masuk

OK,这个没有问题,我也部署成功了。现在我要使用一个第三方开发包:https://packagist.org/packages/levi/lv,修改composer.json如下:

<code>{
    "require" : {
        "php": "5.6.3",
        "levi/lv" : "dev-master",
        "ext-redis" : "*"
    }
}
</code>
Salin selepas log masuk
Salin selepas log masuk

就部署不成功了,错误提示如下:

<code>2015-02-08T18:20:55.67+0800 [API]     OUT Updated app with guid d645cb8f-2ec6-404f-89e7-0795b8ede261 ({"state"=>"STOPPED"})
2015-02-08T18:22:23.10+0800 [DEA]     OUT Got staging request for app with id d645cb8f-2ec6-404f-89e7-0795b8ede261
2015-02-08T18:20:57.88+0800 [API]     OUT Updated app with guid d645cb8f-2ec6-404f-89e7-0795b8ede261 ({"state"=>"STARTED"})
2015-02-08T18:22:25.12+0800 [STG]     OUT -----> Downloaded app package (8.0K)
2015-02-08T18:22:25.31+0800 [STG]     OUT -------> Buildpack version 1.0.2
2015-02-08T18:22:25.48+0800 [STG]     OUT  !     ERROR:        Your composer.json specifies dependencies, but no composer.lock
2015-02-08T18:22:25.48+0800 [STG]     OUT        was found, please check it into your repository along with composer.json!
2015-02-08T18:22:25.48+0800 [STG]     OUT Staging failed: Buildpack compilation step failed
2015-02-08T18:20:58.56+0800 [API]     ERR Encountered error: Staging error: failed to stage application:
2015-02-08T18:20:58.56+0800 [API]     ERR Script exited with status 1
</code>
Salin selepas log masuk
Salin selepas log masuk

我看官方文档有段说明是这样的:

构建

系统会运行以下命令来解决依赖:

<code>install --no-dev --prefer-dist --optimize-autoloader --no-interaction
</code>
Salin selepas log masuk
Salin selepas log masuk

好像是在部署的时候,默认就不执行安装开发包,那么请问如何在coding中安装一个第三方开发包呢?

找到答案
http://ryankent.ca/getting-started-with-laravel-and-php-on-heroku/
http://mattstauffer.co/blog/installing-a-laravel-app-on-heroku

原话如下:

We might also run into some problems with composer because Laravel doesn't add composer.lock to git by default. If you get the following error when pushing to Heroku you need to make sure you remove composer.lock from your .gitignore so it can be pushed correctly.

<code>!     ERROR:        Your composer.json specifies dependencies, but no composer.lock
     was found, please check it into your repository along with composer.json!

!     Push rejected, failed to compile PHP app
</code>
Salin selepas log masuk

意思是确保项目中没有composer.lock。

修改.gitignore,将composer.lock传上来就好了

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan