PHP require Autoload So, I have a good and stable Laravel project running and I went to add a new migration but I keep getting the following errors:
PHP Warning: require(...vendor/autoload.php): failed to open stream: No such file or directory...
If I run composer update then I get the following error:
Composer could not find a composer.json file in...
However I have a composer.json file in my directory ...
Anyone encountered this issue before?
What folder are you currently in? If you are in a subfolder it can give stange errors like this.
@resin I am in the root directory where there are folders such as public, vendor, routes, etc. So the composer.json file should be found
Try with below commands,
composer dump-autoload
nothing happen the use below,
php artisan optimize
composer update
@geowrge yeah I assumed that tbh and because coincidentally I had Windows updates last Friday...
Made sure that files are not set to Read-Only... will have to check again or copy the folder to another directory
Seems to be an issue when working on a folder which is in OneDrive...
Then better to remove vendor folder and try with new ,
composer install
Basically whenever the vendor folder is missing we get this error:
PHP Warning: require(...vendor/autoload.php): failed to open stream: No such file or directory...
The solution is simple, Just run this command:
composer update --no-scripts
composer update
composer update --no-scripts It will Skips execution of scripts defined in composer.json file.
composer update It will update your depencencies as they are specified in composer.json file.
With this command, you will re-create the vendor folder in your project
For this error:
Composer could not find a composer.json file in...
Solution: You are in the wrong directory. Go to your project directory and then run any of your commands in the command prompt
Thanks @UdhavSarvaiya
This is an old post but I just got this error after creating a new Laravel project with php 8.4 and trying to run php artisan serve . So I went back to version 8.3 and ran your commands and now it works.
Hi! Maby your composer.json is corrupt ?
Try :
composer init
This will walk you through creating a new composer.json file. After this, running composer install will download the dependencies.
If everything is set up correctly, your project should recognize the new migration after resolving these issues.
@birdietorerik you will not recover a project this way.
If composer.json is indeed damaged, running init will not create a file that works for laravel
Its a four year old question. Why do you need to chip in with bad advice?
Please sign in or create an account to participate in this conversation.