Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

error creating migration in laravel: 'failed to open stream'

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:

[ErrorException]
include(/home/awa/Desktop/intern/train2/vendor/composer/../../database/migr
ations/2014_10_12_000000_create_users_table.php): failed to open stream: No
such file or directory

what am I doing wrong?

question from:https://stackoverflow.com/questions/40804934/error-creating-migration-in-laravel-failed-to-open-stream

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

also these methods could help:

composer dump-autoload -o
composer update

Composer dump-autoload regenerates the list of all classes that need to be included in the project (autoload_classmap.php).

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...