1、composer功能
composer是php包管理器,就像java有maven,python有pip,ruby有gem,nodejs有npm。
2、composer的原理
composer install原理3、安装composer
原理:下载composer.phar(PHAR为php压缩包)
方式一:(局部安装)
$curl -sS https://getcomposer.org/installer | php
或(制订安装目录)
$curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
方式二:(全局安装)
$curl -sS https://getcomposer.org/installer | php
$mv composer.phar /usr/local/bin/composer
4、简单使用
1)项目目录下创建composer.json文件,指明依赖,比如
{
"require":{
"monolog/monolog":"1.2.*"
}
}
2)安装依赖
composer install
局部安装的情况下:php composer.phar install
5、镜像用法
1)方法一:修改composer的全局配置文件
composer config -g repo.packagist composer https://packagist.phpcomposer.com
2)方法二:修改当前项目的composer.json配置文件
composer config repo.packagist composer https://packagist.phpcomposer.com
或者手动添加:
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
网友评论