近期在用一些扩展或者类库的时候,偶尔会碰到使用Composer生成php包的问题。
总结步骤以下:
window下安装composer:参考
http://www.kankanews.com/ICkengine/archives/28197.shtmlphp
下载:html
Composer官方推荐使用安装包进行安装,听说下载Composer-Setup.exe这个便可用向导模式安装。react
安装完毕后,使用命令行定位到须要生成代码的目录。
在目录下建立一个composer.json的文件。格式为: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 cachepromise
- Installing guzzlehttp/streams (3.0.0)
Loading from cachecomposer
- Installing guzzlehttp/ringphp (1.0.0)
Loading from cache网站
- Installing guzzlehttp/guzzle (5.0.0)
Loading from cacheui
Writing lock file
Generating autoload filesspa
生成成功。命令行
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/