迁移时未找到Laravel致命错误类 [英] Laravel Fatal Error Class Not Found when migrating

查看:98
本文介绍了迁移时未找到Laravel致命错误类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我已经运行了artisan migrate:reset.
  2. 我删除了一些迁移文件,因为我不再需要这些表.
  3. 我先依次运行composer dump-autoloadartisan dump-autoload
  4. 我运行了artisan migrate,并且不断收到此错误:

  1. I've run artisan migrate:reset.
  2. I've deleted some of my migration files because I didn't need these tables anymore.
  3. I ran composer dump-autoload followed by artisan dump-autoload
  4. I ran artisan migrate and I keep getting this error:

PHP致命错误:在第297行的/vagrant/LaravelBackend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php中找不到类"Foo"

我试图:

  • 再次运行composer dump-autoloadartisan dump-autoload(也使用artisan clear-compiled)
  • 删除迁移表并运行artisan migrate:install
  • 删除vendor和composer.lock文件并运行composer install
  • 使用PHPStorm在我的项目中搜索类Foo.没找到任何东西.

  • Run again composer dump-autoload and artisan dump-autoload (also used artisan clear-compiled)
  • Remove the migration table and run artisan migrate:install
  • Remove the vendor and composer.lock file and run composer install
  • Search within my project with PHPStorm for class Foo. Didn't find anything.

我不断遇到同样的错误.自从我更新到4.2以来,这是我第一次运行它,如果可以的话.我还要寻找什么吗?

I keep getting the same error. It's the first time I run this since I updated to 4.2 if that could be related. Anything else I should be looking for?

推荐答案

我通过

  1. 删除所有迁移
  2. 运行composer dump-autoload
  3. 将它们一个接一个地添加并运行php artisan migrate
  4. 删除导致Laravel引发错误的内容
  5. 创建新迁移以替换已删除的迁移
  1. Removing all migration
  2. Running composer dump-autoload
  3. Adding them back one by one and running php artisan migrate
  4. Deleting those that caused Laravel to throw an error
  5. Create new migrations to replace the deleted ones

我不确定为什么能奏效,但我想过去我可能已经修改了这些有问题的迁移的类名.

I'm not sure why that worked but my guess is that I might have modified the class name of these problematic migrations in the past.

我还发现,使用迁移的初始名称(致命错误引发的迁移)重命名迁移同样适用于其中一些.

I also found that renaming the migration with its initial name (The one throwed with the fatal error) also works for some of them.

这篇关于迁移时未找到Laravel致命错误类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆