Home > Backend Development > PHP Tutorial > Laravel执行migrate操作提示”Class not found”

Laravel执行migrate操作提示”Class not found”

WBOY
Release: 2016-06-23 13:12:06
Original
1550 people have browsed it

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

一开始报错如下:

[root@iZ94r80gdghZtanteng.me]# php artisan migrate:reset                                                          [Symfony\Component\Debug\Exception\FatalThrowableError]  Fatalerror: Class 'CreateAttachmentTable' not found
Copy after login

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

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

[root@iZ94r80gdghZtanteng.me]# composer dump-autoloadGeneratingautoloadfiles[root@iZ94r80gdghZtanteng.me]# php artisan migrate:resetRolledback: 2016_03_30_104849_create_attachment_tableRolledback: 2016_03_07_094057_create_admins_tableRolledback: 2016_02_22_102354_entrust_setup_tablesRolledback: 2016_02_22_091444_my_ask_anwser_tableRolledback: 2014_10_12_100000_create_password_resets_tableRolledback: 2014_10_12_000000_create_users_table
Copy after login

composer dump-autoload的作用

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

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template