Laravel 4 migration: class not found exception

梦想与她 提交于 2020-01-13 12:12:54

问题


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.


回答1:


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




回答2:


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.




回答3:


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




回答4:


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.




回答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"



来源:https://stackoverflow.com/questions/18551002/laravel-4-migration-class-not-found-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!