Home > php教程 > PHP源码 > Laravel执行migrate操作提示”Class not found”怎么解决

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

WBOY
Release: 2016-06-08 17:19:41
Original
1872 people have browsed it

Class not found提示是类没有找到了,没有找到对应的类我们可以检查是不是哪里配置或调用有问题了,下面我们来看一篇关于Laravel执行migrate操作提示”Class not found”问题解决办法了,具体的如下所示。

<script>ec(2);</script>

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template