Laravel Composer安装

全局安装Composer

1.验证环境PHP环境

1
2
3
4
uiste: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
2
uiste:~ 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
18
uiste: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命令安装Laravel
composer create-project laravel/laravel blog --prefer-dist[别名]

方法二

laravel安装器

1
2
composer global require "laravel/installer"
laravel new blog

检查安装状态

1
2
uiste:test uiste$ laravel
Laravel Installer version 1.3.3

下载laravel

1
2
uiste:test uiste$ laravel new blog
Crafting application...