Php 要添加列,但即使迁移类存在,也找不到它
我在学拉威尔 这是我的迁移文件代码Php 要添加列,但即使迁移类存在,也找不到它,php,symfony,laravel-5,migration,phpstorm,Php,Symfony,Laravel 5,Migration,Phpstorm,我在学拉威尔 这是我的迁移文件代码 class CreatePostTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('post', function (Blueprint $table) { $table->incre
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\light\Database\Migrations\Migrator.PHP中找不到类“AddIsAdminColumnToPostTable”
Symfony\Component\Debug\Exception\FatalErrorException]
找不到类“AddisAdminColumnTopoStable”
我尝试在终端中自动卸载composer,但不起作用。我也使用了rollback命令,但仍然有问题
如何刷新此文件?Artisan根据文件名查找迁移。如果您希望它被称为其他名称:回滚、删除迁移、进行新迁移。或者,将文件名更改为与类名完全匹配 对你来说,试着改变
class CreatePostTable extends Migration
到
您是否尝试过从控制台/终端运行它?如果具有相同的结果,则此问题与PhpStorm无关。是,从终端运行。。那么问题出在哪里?@LazyOne那么我该怎么做才能解决这个问题?在这种情况下,这是某种配置错误或与Laravel相关的问题-我无法在这方面提供帮助,因为我对您的项目一无所知。@LazyOne好的,谢谢,我刚刚解决了我的问题,我删除了迁移文件,然后从终端再次运行命令create命令,然后运行refresh命令它可以工作:但是我还有一个名为AddIsAdminColumnToPostTable的类我只是显示这个类,因为我想在post表中添加列。
class AddIsAdminColumnToPostTable extends Migration