Laravel Fatal Error Class Not Found when migrating

Wistar picture Wistar · Jun 25, 2014 · Viewed 30.7k times · Source
  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 Fatal error: Class 'Foo' not found in /vagrant/LaravelBackend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 297

I tried to:

  • 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.

    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?

Answer

Juljan picture Juljan · Dec 8, 2014

I had this problem too. Must remember: class name must be in accordance with filename. Simple file renaming helped me:)

For example: in file "2014_12_08_100923_create_items_tables.php" must be class with name "CreateItemsTables" with using CamelCase words.