Home » Php » mysql – Laravel classloader.php error failed to open stream: No such file or directory

mysql – Laravel classloader.php error failed to open stream: No such file or directory

Posted by: admin April 23, 2020 Leave a comment

Questions:

I am able to run “php artisan migrate” fine. I’m able to get all the form input if I use Request::all() but when I try to add the data to my mysql database table I get the below error:

ErrorException in ClassLoader.php line 412:
include(Correct_Path/full-personal/database/migrations/2015_07_06_035501_resume_requesters.php): failed to open stream: No such file or directory

I currently have the form attached to a controller method with the below code:

 $input = Request::all();
    ResumeRequesters::create($input);

I know that I am properly connected to mysql server because I’m able to migrate my migrations.

Any help would be great. Also why did laravel change so many things in Laravel 5?

Thanks

How to&Answers:

You have to run composer dumpautoload inside your project folder.

Answer:

ClassLoader.php Load the given class file into Laravel. Similar errors are due to failure to autoload new classes.

composer dump-autoload

composer dump-autoload regenerates the list of all classes that need to be included in the project (autoload_classmap.php). It won’t download anything.

When to use:
When you have a new class inside your project, Run it from the project root.

Answer:

This has happened to me in my Windows 10 machine using a 2 years-old Laravel project from bitbucket. If the composer dump-autoload won’t work for you, then the error tells you that a directory is missing in my case, there was no migrations folder inside the database directory.

Solution:
Create the migrations folder inside the database directory. You can do this using your IDE, or Windows’s File Explorer. If your using Git Bash, cd to your project’s database folder then do mkdir migrations to create the missing migrations directory.