Hello Magento Geeks,
I am back to solve another error you might be facing in Magento 2. Today it’s about the “Failed to open stream: No such file or directory in composer autoload_real.php” error in Magento 2. Before this, I also shared the solution for PHP Fatal Error “Call to Undefined Function str_contains()” After Upgrading to Magento 2.4.x – Click Here to solve
While working on projects, our developer came across an error and tried resolving it. With serious efforts, they finally solved the error. Hence, we decided to share with you all so that it becomes easy if you come across this error in the future. Let’s know more about the composer autoload error.
Introduction:
When we run the below command in the terminal for uninstalling a module via composer,
php bin/magento module:uninstall Vendor_Extension --clear-static-content
The following error appeared in the terminal as well as localhost,
Warning: require(/var/www/html/M243/vendor/composer/../magento/module-contact/registration.php): failed to open stream: No such file or directory in /var/www/html/M243/vendor/composer/autoload_real.php on line 73
Fatal error: require(): Failed opening required ‘/var/www/html/M243/vendor/composer/../magento/module-contact/registration.php’ (include_path=’/var/www/html/M243/vendor/magento/zendframework1/library:.:/usr/share/php’) in /var/www/html/M243/vendor/composer/autoload_real.php on line 73
Error on site
Error on terminal
So let us know how we fixed this error.
How to Fix Failed to open stream: No such file or directory in composer autoload_real.php Error in Magento 2?
You just need to run the below command in the Magento root directory
composer dumpautoload
Conclusion:
Very simple, right? This way you can solve the “Failed to open stream: No such file or directory in composer autoload_real.php” error in Magento 2. Let me know if the error still persists. If you face any other errors while working with Magento 2, reach out to our Experienced Magento Developers.
Share the article with your other Magento friends and stay in touch with us for more instructive guides on Magento.
Happy Coding!