首先,你得配置好 php 的環境變量。建議php版本在5.4及以上版本。php
下載並執行 https://getcomposer.org/Composer-Setup.exelinux
@ECHO OFF php "%~dp0composer.phar" %*
再雙擊執行
3. 黑窗口執行 composer -v 是否執行成功
4. 添加國內源json
composer config -g repo.packagist composer https://packagist.phpcomposer.com
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer update 安裝composer.json的所有的包
composer require monolog/monolog 安裝指定的包(monolog/monolog)
composer update monolog/monolog 更新指定的包(monolog/monolog)
composer remove monolog/monolog 移除指定的包(monolog/monolog)
composer dump-autoload 手動更新composer.jsonwindows
composer clear-cache 清除緩存
composer self-update 更新到最新版本
composer dumpauto 更新自動加載項
composer validate 檢測composer.json 文件是否有效
composer create-project 基於composer建立一個新的項目 **緩存
在linux下執行composer相關命令,能夠遇到以下錯誤:composer
問題:/usr/bin/env: php: No such file or directory
緣由:php沒有安裝在/usr/local/bin
解決方案:創建軟連接 ln -s /usr/local/php/bin/php /usr/local/bin/phpcurl