composer基础及应用
2018-11-11 本文已影响0人
noone_5304
composer是PHP的依赖管理工具可以声明项目所依赖的代码库
安装:
下载: getcomposer.org/download
linux(ubuntu):
curl -sS https://getcomposer.org/install | php
//mv composer.phar /usr/local/bin/composer (全局安装,如果不需要,则可不执行)
Mac:
brew update
brew tap josegonzalez/homebrew-php
brew tap homebrew/versions
brew install php55-intl
brew install josegonzalez/php/composer
更换国内镜像
composer config -g repositories.packagist composer https://packagist.phpcomposer.com
常用命令
install 安装依赖包:
composer install即可安装到项目目录,安装后项目目录会出现composer.lock文件composer通过它来锁定版本
此时如果依赖库需要更新则是使用update 命令 composer update 来更新项目依赖包
install参数
--prefer-source composer将从源安装
--prefer-dist composer将直接获取,速度更快
--dry-run 模拟安装
create-project创建依赖包项目:
composer create-project vendor/vendor project
添加依赖:
composer require
升级composer:
composer self-update
搜索依赖包:
composer search vendor