全局安装Composer
1.验证环境PHP环境1
2
3
4uiste:Downloads uiste$ php -v
PHP 5.6.24 (cli) (built: Aug 8 2015 16:58:37)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
2.监测包安装文件uiste:Downloads uiste$ php composer.phar
3.移动文件到全局目录uiste:Downloads uiste$ sudo mv composer.phar /usr/local/bin/composer
若没有访问权限
1
2
3
4
5
6
7 >uiste:Downloads uiste$ composer
>-bash: /usr/local/bin/composer: Permission denied
>uiste:Downloads uiste$ cd /usr/local/bin/
>uiste:bin uiste$ ls -l
>....
>uiste:bin uiste$ sudo chmod -R 755 composer
>
4.切换到任意目录验证uiste:~ uiste$ composer
中国全量镜像
查看当前的镜像地址1
2uiste:~ uiste$ composer config -g repo.packagist
{"type":"composer","url":"https:\/\/packagist.phpcomposer.com"}
uiste:~ uiste$ composer config -g repo.packagist composer https://packagist.phpcomposer.com
使用Composer
主要命令
搜索:search
展示:show
声明依赖:require
安装:install
更新:update
uiste:test uiste$ composer search monolog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18uiste:test uiste$ vim composer.json
{
"name": "imooc/test",
"description": "test composer",
"authors": [
{
"name": "uiste",
"email": "798407452@qq.com"
}
],
"require": {
"monolog/monolog":"1.21.*",
"symfony/http-foundation": "^3.1"
}
}
uiste:test uiste$ composer install
uiste:test uiste$ composer require symfony/http-foundation
Composer安装laravel框架
方法一
通过 composer Create-Project命令安装Laravelcomposer create-project laravel/laravel blog --prefer-dist[别名]
方法二
laravel安装器1
2composer global require "laravel/installer"
laravel new blog
检查安装状态1
2uiste:test uiste$ laravel
Laravel Installer version 1.3.3
下载laravel1
2uiste:test uiste$ laravel new blog
Crafting application...