windows----composer、laravel安装

环境要求:php+apache,并且将php的根目录配置到“环境变量”。

1.安装composer

使用cmd进入想要安装composer的目录执行如下命令,下载composer.phar文件:

php -r "readfile('http://install.phpcomposer.com/installer');" | php

在composer安装目录下新建composer.bat文件,代码如下:

@php "%~dp0composer.phar" %*

将composer安装目录配置到系统的环境变量,composer安装完毕。

此时使用cmd执行如下命令可以看到composer的版本信息:Composer version 1.0-dev (72cd6afdfce16f36a9fd786bc1b2f32b851e764f) 2015-12-28 17:35:19

composer -v

2.安装laravel

下载laravel安装包,下载路径:http://www.golaravel.com/download。

将下载的文件解压放在项目的根目录,例如博客项目根目录为:e:/blog,那么它的目录结构如下图:

windows----composer、laravel安装

使用cmd进入目录e:/blog,执行如下命令:

composer install

到这里laravel安装完毕。

laravel必须要求apache开启mod_rewrite模块,

将apache的根目录设置到e:/blog/public,使用浏览器打开:http://locahost,你可以看到“Laravel 5”的图案。(注意Apache设置的端口)

设置如下:

DocumentRoot "e:/blog/public"
<Directory "e:/blog/public">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

注意:AllowOverride 必须改为"All"。

3.启用composer的全量中国镜像

使用cmd进入项目根目录e:/blog,执行如下命令:

composer config repo.packagist composer http://packagist.phpcomposer.com

然后打下根目录下的composer.json文件,在文件末尾你可以看到如下代码,说明启用成功:

"repositories": {
        "packagist": {
            "type": "composer",
            "url": "http://packagist.phpcomposer.com"
        }
    }