Laravel for Windows 开发环境配置


本文为CSDN Choris 原创,转载请事先征得作者同意,以示尊重!

原文:http://blog.csdn.net/choris/article/details/50215835

Laravel配置教程

本文在参考岁寒博客Laravel 5 系列入门教程(一)【最适合中国人的 Laravel 教程】的基础上写成1。

PHP开发框架,用Laravel框架开发的网站需要运行于有PHP+数据库+web服务器的操作系统上。一般要求PHP版本5.4+,MySQL5.1+。本文选择PHP+MySQL数据库+Apache web服务器。在Windows下可以下载并安装最新版XAMPP集成开发环境,点击到XAMPP官网下载。

Composer中文网下载2。 
安装完成后输入以下指令检测是否安装成功:

composer -V

Composer中文网的教程配置3,本文下面也会详述配置步骤。

Linux、Mac用户)并执行如下命令:

composer config -g repositories.packagist composer http://packagist.phpcomposer.com

Git. See https://getcomposer.org/doc/06-config.md#secure-http for details.

解决方法是设置一个本地或全局的composer配置:

composer config secure-http false

全局设置:

composer config -g secure-http false

意义是默认禁用https请求,就可以了

安装完成后在当前目录下会生成一个目录learnlaravel5,如下图所示: 
这里写图片描述

打开xampp并开启Apache服务器,在浏览器中输入Laravel主目录:

“ip:端口/laravel安装目录 / public” (默认80端口可省略)
在我的本机上为:
localhost/learnlaravel5/public

可以看到Laravel安装成功地界面: 
这里写图片描述


Laravel 出现"RuntimeException inview plain copy    在CODE上查看代码片派生到我的代码片
  1. php artisan key:generate  

效果:

这时候项目根目录下的.env文件里的APP_KEY应该会有值了:

若没有,则将上一步生成的key值输入进去即可。

Laravel Migration Error : Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes laravel 5.3

Refering to Laravel News and Laravel's migration guide:

As outlined in the Migrations guide to fix this all you have to do is edit your AppServiceProvider.php file and inside the boot method set a default string length:

use Illuminate\Support\Facades\Schema;

function boot()
{
    Schema::defaultStringLength(191);
}

深入理解 Laravel Eloquent(一)——基本概念及用法

接下来进行 Article 和 Page 类对应的 articles 表和 pages表的数据库迁移,进入 learnlaravel5/database/migrations 文件夹。 
在 ***_create_articles_table.php 中修改:

Schema::create('articles', function(Blueprint $table)
{
    $table->increments('id');
    $table->string('title');
    $table->string('slug')->nullable();
    $table->text('body')->nullable();
    $table->string('image')->nullable();
    $table->integer('user_id');
    $table->timestamps();
});

在 ***_create_pages_table.php 中修改:

Schema::create('pages', function(Blueprint $table)
{
    $table->increments('id');
    $table->string('title');
    $table->string('slug')->nullable();
    $table->text('body')->nullable();
    $table->integer('user_id');
    $table->timestamps();
});

然后执行命令

php artisan migrate

成功以后, articles 表和 pages 表已经出现在了数据库里。

岁寒博客Laravel 5 系列入门教程(一)【最适合中国人的 Laravel 教程】 ?
  • Composer中文网 ?
  • Composer全量中国镜像 ?
  • http://stackoverflow.com/questions/28468625/laravel-5-failed-opening-required-bootstrap-vendor-autoload-php
  • http://blog.csdn.net/u013049553/article/details/52608353
  • wnmp环境搭建:http://www.cnblogs.com/wuzhenbo/p/3493518.html
  • http://stackoverflow.com/questions/43384273/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-w
  •