1

我在 PHP 5.6.16 服务器上使用 Laravel 5.2.45。

使用 php artisan migrate:refresh / migrate:reset 命令时,我收到此错误:

 [Symfony\Component\Debug\Exception\FatalErrorException]
  Class 'AddSourceInClotureTable' not found

请注意, migrate 和 migrate:rollback 正在工作。

我尝试了谷歌搜索(不是单个结果:AddSourceInClotureTable),并尝试了 composer update、composer dumpauto、cache:clear 以及可能任何单个命令工匠都可以执行的操作。

这是我在项目中的单个迁移文件:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommandTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commands', function (Blueprint $table) {
            $table->increments('id');
            $table->integer("provider");
            $table->string("number")->unique();;
            $table->date("delivered_at");
            $table->date("ordered_at");
            $table->integer("buyer");
            $table->boolean("deliver_mode");
            $table->integer("payment");
            $table->timestamps();
        });
        Schema::create('payment', function (Blueprint $table) {
            $table->increments('id');
            $table->string("name");
            $table->timestamps();
        });
        Schema::create('transports', function (Blueprint $table) {
            $table->increments('id');
            $table->string("name", 255)->unique();
            $table->string("code", 255)->unique();
            $table->integer("carrier");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('commands');
        Schema::drop('payment');
        Schema::drop('transports');
    }
}

这是我的 composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "barryvdh/laravel-ide-helper": "^2.1",
        "laravelcollective/html": "5.2.*",
        "barryvdh/laravel-dompdf": "0.6.*",
        "caffeinated/flash": "~2.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "symfony/css-selector": "2.8.*|3.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

有任何想法吗 ?

4

2 回答 2

1

每次执行命令后,您应该始终运行composer dumpauto或它的别名命令:composer dump-autoloadmigrate

如果在运行迁移时收到“找不到类”错误,请尝试运行该composer dump-autoload命令并重新发出 migrate 命令。

https://laravel.com/docs/5.2/migrations#running-migrations

于 2016-09-18T12:03:56.660 回答
0

该项目与前一个项目重复,迁移表未重命名。这里是人为错误。一旦给了一个新名字,所有的错误都消失了。

于 2016-09-18T19:41:55.280 回答