Laravel Migration – Error Exception Failed to Open Stream

Laravel migrations is one of the powerful feature to work with Laravel Database. Working with migrations in laravel  generates number of errors including Specified key was too Long. Facing the error after running laravel migration “Error Exception Failed to Open Stream”. Why Failed to Open Stream?. Failed to open stream occurs when you already run […]

Laravel migrations is one of the powerful feature to work with Laravel Database. Working with migrations in laravel  generates number of errors including Specified key was too Long. Facing the error after running laravel migration “Error Exception Failed to Open Stream”.

Why Failed to Open Stream?.

Failed to open stream occurs when you already run migration and then delete your table migration file from (your-project > app > database > migrations). Manually deleting migration file generates error.

[ErrorException] include([directory of file]): failed to open stream: No such file or directory

1. Failed to Open Stream – Laravel Solution:

Delete table file from migration folder in laravel without using migration:rollback generates the error. “failed to open stream: No such file or directory”. Artisan refuse to create the file, until you use dump-autoload in composer.

  1. Open your command prompt to run composer commands.
  2. Running the command dump-autoload can save your day.
composer dump-autoload

2. Delete Migration Entry from phpMyAdmin:

Laravel Migration “Failed to Open Stream”  error could be solved via deleting the entry from phpMyAdmin. Delete the row from migration table points laravel, table is not exists. Laravel then allows migration to run smoothly.

  1. Open your phpMyAdmin and navigate to your Database.
  2. Browse your Migration Table.
  3. Delete the entry which is already registered with the name of your table.

3. Run Migrate Rollback

Migrate rollback is one of the best feature to delete all entries. Rollback and Re-run your migration. Rollback helps you to create a stable state for your database.

Run php artisan migrate:rollback until your database meets your desired state.


Wrap Up:

Guideline for the beginners to use rollback call and run your migration again and again until you find a stable state. Update your table and run your migration can solve numbers of problems.

Consider reading  Specified key was too Long laravel 5.4. When you define foreign key to a table you will face the error.

Leave a Reply

Your email address will not be published. Required fields are marked *