curl -sS https://getcomposer.org/installer | php //下载composer.phar 可执行文件
要检查 Composer 是否正常工作,只需要通过 php 来执行 PHAR:
php composer.phar
//
sudo cp composer.phar /usr/local/bin/composer
//执行composer验证,如果执行失败,进入/usr/local/bin/修改composer的权限
ls -al 查看用户权限
sudo chmod -R 755 composer 修改权限
执行composer
如果出现
安装成功
配置中国镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
init composer
进入新建文件夹下执行
composer init
vi composer.json
composer search monolog
composer show --all monolog/monolog
在composer.json中加入monolog/monolog,类似cocopods中的Podfile文件
{
"name": "imooc/test",
"description": "test",
"type": "library",
"authors": [
{
"name": "Zhang Jiandong",
"email": "jiandong_zhang@boyitimes.com"
}
],
"require": {
"monolog/monolog": "1.21.*"
}
}
//安装更新-此命令自动下载monolog
composer install
composer 安装laravel
composer search laravel //显示出laravel包
composer show --all laravel/laravel // 可以显示出包名(name) 描述(descrip) 版本(versions)等
// 直接安装,默认安装的最新版 composer create-project --prefer-dist laravel/laravel (文件名) // 安装制定版本的 laravel composer create-project --prefer-dist laravel/laravel blog 5.6.*
// 阿里云镜像 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ // 阿里云镜像