问题描述
我使用以下命令创建了我的第一个迁移create_users_migration
:
I created my first migration create_users_migration
using the command:
php artisan make:migration create_users_table
我后来意识到存在错误,因此删除了迁移文件,并决定使用上面的相同命令创建不同的迁移文件.但是它总是抛出此异常:
I later on realized there was an error and so deleted the migration file and decided to create different migration file with the same command above. But it keeps throwing this exception:
我在做什么错了?
推荐答案
我会定期收到此错误,以下一些内容可能会有所帮助:
I get this error on regular basis, here are some things that might help:
php artisan cache:clear
或在引导目录中手动删除缓存(它负责路由和服务缓存.
or delete the cache manually in the bootstrap directory (it is responsible for the route and services cache.
这些方法也可以帮助您
composer dump-autoload -o
composer update
Composer dump-autoload重新生成需要包含在项目中的所有类的列表(autoload_classmap.php).
Composer dump-autoload regenerates the list of all classes that need to be included in the project (autoload_classmap.php).
-o/--optimize 选项将PSR-4/PSR-0规则转换为类映射规则,因此自动加载器不需要访问文件系统,从而使其运行得更快-这也是问题的根源,因为Laravel自动加载器使用了这种优化(缓存).
the -o / --optimize option converts PSR-4/PSR-0 rules into classmap rules, as a result autoloader doesn't need to access the filesystem, making it run faster - which also is often the source of the problem since Laravel autoloader uses this optimization (caching).
还回滚了迁移,多次帮助解决了该问题(如果迁移成功):
also rolling back the migration has helped to solve the problem several times (if the migration was successful):
php artisan migrate:rollback
这篇关于在laravel中创建迁移时出错:“无法打开流"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!