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.
- Open your command prompt to run composer commands.
- Running the command
dump-autoloadcan save your day.
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.
- Open your phpMyAdmin and navigate to your Database.
- Browse your
- 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.
php artisan migrate:rollback until your database meets your desired state.
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.