Laravel 4 迁移:找不到类异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18551002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 4 migration: class not found exception
提问by KennyV
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.
我的 composer.json 也会自动加载迁移。
回答by Amin Behravesh
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:
我遇到了同样的问题,我在互联网上搜索并找到了这个解决方案,您应该使用此 composer 命令更新自动生成的类映射(又名自动加载):
php composer.phar update
or
或者
composer update
check this link : I found the solution here
检查此链接:我在这里找到了解决方案
回答by KennyV
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.
等等。显然这给了我错误,它真的必须保持在“ yyyy_mm_dd_hhmmss_create_xxx_table.php”格式。
回答by user3281319
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
如果composer dump-autoload
不起作用,请检查迁移文件中的类名。className 应该与没有日期的文件名相同
回答by user1645377
I had the same problem.
我有同样的问题。
For me, composer update
doesn't work (in other situations as well) with Windows for weird reasons.
对我来说,composer update
由于奇怪的原因在 Windows 上不起作用(在其他情况下也是如此)。
But,
但,
composer dump-autoload
works.
作品。
回答by César Eduardo Cárdenas Fuentes
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"
删除行并刷新迁移并执行“composer dump-autoload -o”