【发布时间】:2017-10-04 08:12:16
【问题描述】:
当我在 Laravel 中运行 php artisan migrate 为我的数据库创建表时,出现以下错误:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected 'string' (T_STRING), expecting variable (T_VARIABLE)
我认为这个错误毫无用处,因为它没有告诉我在哪个文件中,以及在什么地方出了问题(这让我很难理解发生了什么)。
第一次迁移似乎失败了,因为它没有在我的数据库中生成单个表。
这是迁移(用户 -> 使用 php artisan make:auth 生成):
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->string('avatar');
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('users');
}
}
这只是一个新行的默认迁移。我不知道它有什么问题。我已经尝试过composer dump-autoload 和composer clearcache,但没有任何效果。
我希望有人知道解决方案。
编辑:它似乎发生在第一次迁移运行之前。是否存在可能有问题的文件?
你可以在这里阅读我的 Laravel.log 文件:https://pastebin.com/1PrDwady
【问题讨论】:
-
这是什么? $table->头像('密码');
标签: laravel laravel-5 composer-php laravel-5.4 laravel-artisan