Laravel 5.5 踩坑指南

1. 没有storage目录的访问权限

The stream or file "/Applications/MAMP/htdocs/portfolio/storage/logs/laravel.log" could not be opened
  : failed to open stream: Permission denied

解决方案:

sudo chmod -R 777 /Applications/MAMP/htdocs/portfolio/storage

2. 表已经存在

Base table or view already exists: 1050 Table 'users' already exists

解决方案:
打开创建表的那个 migration 文件,在创建表的方法执行之前加一个判断条件

if (!Schema::hasTable('password_resets')) {
    Schema::create('password_resets', function (Blueprint $table) {
        $table->string('email')->index();
        $table->string('token');
        $table->timestamp('created_at')->nullable();
    });
}

3. 字符集长度不够

Syntax error or access violation: 1071 Specified key was too long; max key  
   length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))   

解决方案:
打开 AppServiceProvider.php,copy 如下内容替换

4. mysql 不允许0作为默认时间

Syntax error or access violation: 1064 You have an error in your SQL syntax; check t
  he manual that corresponds to your MySQL server version for the right syntax to use near 'published_a
  t) null, `updated_at` timestamp(published_at) null, `created_at` time' at line 1

解决方案:

  1. 打开表的那个 migration 文件,用如下内容替换时间戳部分
$table->timestamp('published_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
  1. 修改MYSQL配置文件的 NO_ZERO_DATE 值

5. APP_NAME 不能有空格,如果有空格需要加上双引号

Dotenv values containing spaces must be surrounded by quotes.

解决方案:
打开.env,给APP_NAME 的值加上双引号即可,比如

APP_NAME="Living Water"

6. 没有接口访问权限

php artisan passport:install

你可能感兴趣的:(Laravel 5.5 踩坑指南)