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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM