【发布时间】:2017-04-27 15:32:02
【问题描述】:
我正在学习 Laravel。
这是我的迁移文件代码。
class CreatePostTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('post', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned(); // i want to add this column after adding this line i runs the command refresh but it shows below errors.
$table->string('title');
$table->text('body');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('post');
}
}
现在我有一个问题,每当我在 PhpStorm 的终端中运行此命令时:
php artisan migrate:refresh
它显示以下错误:
PHP 致命错误:第 335 行的 C:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php 中找不到类“AddIsAdminColumnToPostTable”
Symfony\Component\Debug\Exception\FatalErrorException] 找不到类“AddIsAdminColumnToPostTable”
我在终端 solution from here 中尝试了 composer dump-autoload,但它不起作用。我也使用了rollback 命令,但仍然有问题。
refresh怎么可以这样?
【问题讨论】:
-
你试过从控制台/终端运行它吗?如果结果相同(不起作用),那么这个问题与 PhpStorm 无关。
-
是的,从终端运行.. 那么问题出在哪里?
-
@LazyOne 那我该怎么做才能解决这个问题?
-
在这种情况下,这是某种错误配置或与 Laravel 相关的问题——在这方面我无能为力,因为我不知道你的项目。
-
@LazyOne 好的,谢谢,我刚刚解决了我的问题,我删除了迁移文件,然后再次从终端运行命令 create 命令,然后运行它可以工作的刷新命令 :)
标签: php symfony laravel-5 migration phpstorm