KennyV
KennyV

Reputation: 832

Laravel 4 migration: class not found exception

So apparently now I get this weird error when I want to migrate my database

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class '' not found","file":"C:\\xampp\\htdocs\\l4crm\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Migrations\\Migrator.php","line":301}}[Finished in 1.3s]

Everything used to work of course and it doesn't matter which files I try to migrate (I tried only migrating one table, then another, they all give the same error)

Any ideas? I have been staring myself blind at this for over an hour now.

Also "composer dump-autoload" does not do the trick.

My composer.json autoloads the migrations also.

Upvotes: 4

Views: 9328

Answers (5)

In my case, i had deleted a migration in source files but i didn't on "migrations" table on the database.

Delete the row and refresh migrations and do a "composer dump-autoload -o"

Upvotes: 0

Ethan
Ethan

Reputation: 365

I had the same problem.

For me, composer update doesn't work (in other situations as well) with Windows for weird reasons.

But,

composer dump-autoload

works.

Upvotes: 3

Amin Behravesh
Amin Behravesh

Reputation: 374

I had the same problem, I searched the internet and I found this solution that you should update your auto-generated classmap (aka autoload) with this composer command:

php composer.phar update

or

composer update    

check this link : I found the solution here

Upvotes: 11

user3281319
user3281319

Reputation: 31

if composer dump-autoload doesn't work, check your class name in the migration file. The className should be the same than the file name without the date

Upvotes: 3

KennyV
KennyV

Reputation: 832

I appear to have solved the problem.

For easiness sake to determine the order of migrations I had renamed the migration files to something like

1_create_users_table.php
2_create_..._table.php
3_create_..._table.php

and so on. Apparently this gave me the error, it really had to stay in the "yyyy_mm_dd_hhmmss_create_xxx_table.php" format.

Upvotes: 9

Related Questions