Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 358
Awa Melvine Avatar asked Nov 25 '16 12:11

Awa Melvine


3 Answers

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
like image 156
Aleksei Maide Avatar answered Nov 13 '22 03:11

Aleksei Maide


i got this error and i have found a solutions over the community :

php artisan cache:clear

this will delete cached files

composer dump-autoload

composer dump-autoload, will re-generating optimized autoload files for your project agian

php artisan migrate:refresh

then create a new fresh migrate for your database

php artisan make:migration create_users_table --create=users

finally let's start make your new migration file

like image 43
Ro Vinei Avatar answered Nov 13 '22 04:11

Ro Vinei


You might then need to run composer dump-autoload

like image 9
Aleksey Boyko Avatar answered Nov 13 '22 04:11

Aleksey Boyko