larveral|Laravel执行migrate操作提示”Class not found”怎么解决

时间:2020-09-05  来源:上传工具  阅读:

使用Laravel的artisan命令工具执行migrate操作,提示”Class not found”的错误,但是这个migrate类文件是存在的,如遇到这个问题,可执行以下composer dump-autoload,问题得到解决。

一开始报错如下:


[root@iZ94r80gdghZ tanteng.me]# php artisan migrate:reset
                                                          
[Symfony\Component\Debug\Exception\FatalThrowableError] 
Fatal error: Class "CreateAttachmentTable" not found

无论执行migrate什么操作都提示类找不到。

执行composer dump-autoload后,再次运行migrate操作,一切正常。

[root@iZ94r80gdghZ tanteng.me]# composer dump-autoload
Generating autoload files
[root@iZ94r80gdghZ tanteng.me]# php artisan migrate:reset
Rolled back: 2016_03_30_104849_create_attachment_table
Rolled back: 2016_03_07_094057_create_admins_table
Rolled back: 2016_02_22_102354_entrust_setup_tables
Rolled back: 2016_02_22_091444_my_ask_anwser_table
Rolled back: 2014_10_12_100000_create_password_resets_table
Rolled back: 2014_10_12_000000_create_users_table
composer dump-autoload的作用

composer dump-autoload命令的作用是优化自动加载,当把代码部署到生产环境中,或者增加删除了自动加载文件夹里的类文件,需要执行一下自动加载命令,这样自动加载才会起作用。

larveral|Laravel执行migrate操作提示”Class not found”怎么解决

http://m.bbyears.com/shipin/96935.html

推荐访问:蜡染
相关阅读 猜你喜欢
本类排行 本类最新