【问题标题】:Laravel 5.1.11 migrate with php artisan does not work for meLaravel 5.1.11 迁移与 php artisan 对我不起作用
【发布时间】:2016-02-01 13:48:41
【问题描述】:

我正在使用 Laravel 5.1.11,但是当我尝试运行 php artisan migrate 命令时,我遇到了以下错误消息:

 ****[symfony\Component\Debug\Exception\FatalErrorException] syntax Error, unexpected 'public' (T_PUBLIC)****

database.php.env 中使用数据库连接配置非常好,因为php artisan migrate:install 工作正常。

这是迁移代码:

   **<?php
        use Illuminate\Database\Schema\Blueprint;
        use Illuminate\Database\Migrations\Migration;
        class CreateFlightsTables extends Migration
        {
            /**
             * Run the migrations.
             *
                //
                Schema::create('flights', function (Blueprint $table) {

             * @return void
             */
           public function up()
        {
            //
            Schema::create('flights', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name');
                $table->string('airline');
                $table->timestamps();
        }
            /**
             * Reverse the migrations.
             *
             * @return void
             */
            public function down()
            {
                //
                Schema::drop('flights');
            }
        }**

【问题讨论】:

  • 你能发布一些你的迁移源和迁移中使用的代码吗?该错误看起来像是您的一个文件中存在语法错误,它可能不是迁移。
  • 在此处粘贴您的迁移代码,以便我们查找错误。
  • 注意下面的迁移文件:
  • 请将问题标记为已回答

标签: laravel-5.1 database-migration


【解决方案1】:

尝试将您的function up() 替换为

Schema::create('flights', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->string('airline');
    $table->timestamps();
});

认为您在末尾缺少括号和分号

【讨论】:

    猜你喜欢
    • 2016-02-07
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 2019-05-24
    • 2018-10-03
    • 2016-05-22
    • 2017-10-12
    相关资源
    最近更新 更多