Composer生成PHP依赖包

近期在用一些扩展或者类库的时候,偶尔会碰到使用Composer生成php包的问题。
总结步骤如下:
window下安装composer:参考
http://www.kankanews.com/ICkengine/archives/28197.shtml

下载:

Windows环境

Composer官方推荐使用安装包进行安装,据说下载Composer-Setup.exe这个即可用向导模式安装。

 

安装完毕后,使用命令行定位到需要生成代码的目录。
在目录下创建一个composer.json的文件。格式为:

{
"require": {
"guzzlehttp/guzzle": "~5.0",
"guzzlehttp/guzzle": "~5.0",
}
}

 

使用CMD的composer命令生成代码:
E:\DannyCode\composer>composer install
会生成如下的结果:
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing react/promise (v2.0.0)
Loading from cache

- Installing guzzlehttp/streams (3.0.0)
Loading from cache

- Installing guzzlehttp/ringphp (1.0.0)
Loading from cache

- Installing guzzlehttp/guzzle (5.0.0)
Loading from cache

Writing lock file
Generating autoload files

生成成功。

PS 如果提示:
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "C:\ProgramData\ComposerSetup\bin\composer.phar self-update" to get the latest version.

则需要更新composer:
E:\DannyCode\LogTest>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing react/promise (v2.0.0)
Downloading: 100%

- Installing guzzlehttp/streams (3.0.0)
Downloading: 100%

- Installing guzzlehttp/ringphp (1.0.0)
Downloading: 100%

- Installing guzzlehttp/guzzle (5.0.0)
Downloading: 100%

Writing lock file
Generating autoload files

 

参考网站:

http://www.kankanews.com/ICkengine/archives/28197.shtml

http://blog.lixiphp.com/php-composer-install-and-use/#axzz3BglEg0J6

https://packagist.org/

转载于:https://www.cnblogs.com/dannywang/p/4025105.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值