require(vendor/autoload.php): failed to open stream
require(vendor/autoload.php): failed to open stream
I know that this issue has been posted many times, but for me it seems to be a different problem.
Indeed, this error
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:xampphtdocssite_websend_mail.php on line 3
Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:xamppphpPEAR') in C:xampphtdocssite_websend_mail.php on line 3
appears at the begining of my code from this line:
require 'vendor/autoload.php';
So, I guess there must be a /vendor/autoload.php file somewhere in my computer (I have installed composer and ran composer require phpmailer/phpmailer
composer require phpmailer/phpmailer
).
So, I looked for this file using: dir /s autoload.php in the Windows command line, and found one here: C:WindowsSysWOW64vendorautoload.php,
dir /s autoload.php
C:WindowsSysWOW64vendorautoload.php
but for me, syswow64 folder has nothing to see with autoload.php, I don't see what I am missing here.
Thanks
11 Answers
11
What you're missing is running composer install, which will import your packages and create the vendor folder, along with the autoload script.
composer install
Make sure your relative path is correct. For example the example scripts in PHPMailer are in examples/, below the project root, so the correct relative path to load the composer autoloader from there would be ../vendor/autoload.php.
examples/
../vendor/autoload.php
The autoload.php you found in C:WindowsSysWOW64vendorautoload.php is probably a global composer installation - where you'll usually put things like phpcs, phpunit, phpmd etc.
C:WindowsSysWOW64vendorautoload.php
How do I run composer install? It's not recognised as a command
– Yvonne Aburrow
Mar 16 '17 at 9:41
Go to getcomposer.org and install it as directed.
– Synchro
Mar 16 '17 at 9:55
thanks, found that, and have downloaded it - but it asks me where PHP is installed locally. I don't really want to install PHP locally (or Composer) I just want to run it on my Google Cloud app.
– Yvonne Aburrow
Mar 16 '17 at 10:52
Google cloud for PHP provides composer to install its dependencies, you just need to set it up, see here: cloud.google.com/appengine/docs/flexible/php/…
– Synchro
Mar 16 '17 at 11:04
Yes, google cloud will need to run
composer install and it will then read the contents of your composer.json file and install all your dependencies into the vendor folder. If it's not doing that, I can only suggest reading the docs I pointed at and double-checking it all. This is really the distinction between "upload" and "deployment".– Synchro
Mar 16 '17 at 11:23
composer install
composer.json
vendor
If you get the error also when you run
composer install
Just run this command first
composer dump-autoload
This command will clean up all compiled files and their paths.
@Bashir almost helped me but I needed:
composer update --no-scripts
I found the answer here:
https://laracasts.com/discuss/channels/general-discussion/fatal-error-class-illuminatefoundationapplication-not-found-in-pathtoprojectbootstrapappphp-on-line-14?page=0
autoload.php
A) Quick answer:
Your autoload.php path is wrong. ie. C:WindowsSysWOW64vendorautoload.php
To date: you need to change it to: C:Users<Windows User Name>vendorautoload.php
C:WindowsSysWOW64vendorautoload.php
C:Users<Windows User Name>vendorautoload.php
B) Steps with example:
We will take facebook/php-graph-sdk as an example; change to Package Name as needed.
Package Name
CMD
composer require facebook/graph-sdk
require_once 'C:Users<Windows User Name>vendorautoload.php';
Secrets
Access Token
C) Further details:
Installing composer on windows will set this default path for your pacakges; you can find them there and include the autoloader path:
C:Users<Windows User Name>vendor
For the same question you asked; the answer was this path for WAMP Server 64 BIT for Windows.
Then simply in your PHP Application change this:
require_once __DIR__ . '/vendor/autoload.php';
To:
require_once 'C:Users<Windows User Name>vendorautoload.php';
Find your windows username under C:Users
C:Users
Before all this, as pointed before in B) , you need to run this command:
composer require <package name>
for facebook php SDK for example:
composer require facebook/graph-sdk
Thank you for asking this question; appreciated as it helped me fix similar issue and ended writing this simple tutorial.
I had this path in my machine:
C:/xampp5.0/htdocs/project-recordando-symfony/project-recordando-symfony
Then I ran composer install or/and composer update and it returned this error:
composer install
composer update
ErrorException ZipArchive::extractTo...
That error is because your path is too much long, I changed to:
C:/xampp5.0/htdocs/p-symfony/*
and worked!
First make sure you have installed the composer.
composer install
If you already have installed then update the composer.
update composer
This answer needs serious editing to be helpful to a user. Please clearly state your suggestions and provide code samples that would be useful in this situation.
– Stefan Crain
Apr 26 at 14:48
I was able to resolve by removing composer and reinstalling the proper way. Here is what I did:
I was then able to get composer install to work again. Found my answer at the bottom of this issue: https://github.com/composer/composer/issues/5510
run composer update. That's it
Yeah, thats already part of the accepted answer. Whats the point in duplicating it?
– Nico Haase
Feb 19 at 9:03
check the line above that accepted answer
– Bashir ahmad
Feb 19 at 13:24
It says "7 Answers", so whats the point in reading it?
– Nico Haase
Feb 19 at 21:01
Change the auto_prepend_file property on php.ini
; Automatically add files before PHP document.
;http://php.net/auto-prepend-file
auto_prepend_file =
How does this relate to the question? There is an accepted answer with a completely other solution
– Nico Haase
Feb 19 at 8:03
I had the following error in this morning. "Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0" Therefore I writed this solution.
– ercvs
Feb 19 at 8:48
Only this: composer require symfony/finder
Provide more details on your answer to better understand
– user9405863
Apr 12 at 11:56
***PHP Warning: require_once(C:xampphtdocstest1/bootstrap/app.php): failed to open stream: No such file or directory in C:xampphtdocstest1artisan on line 20
Warning: require_once(C:xampphtdocstest1/bootstrap/app.php): failed to open stream: No such file or directory in C:xampphtdocstest1artisan on line 20
PHP Fatal error: require_once(): Failed opening required 'C:xampphtdocstest1/bootstrap/app.php' (include_path='C:xamppphpPEAR') in C:xampphtdocstest1artisan on line 20
This problem due to the missing of bootstrap file in your project folder..This problem can not fix by using reinstalling or updating composer..
you can fix by using : if you have another project available just open that project and copy bootstrap file folder and past to your missing project folder for example:
i have two project test 1 and test 2
(you can create your project by using cmd => Composer create-project laravel/laravel test 1 ) now go to atom and open project test 1 and test 2 . this error occurs in test 1,you can just copy bootstrap file from test 2 and past to test 1.save changes.. then go to cmd just type php artisan serve .. then your problem is solved.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
This can also occur if you have php artisan up or down in your composer.json file in the scripts section on pre-install. It seems to need files in the vendor folder to execute the maintenance mode, which isn't available as yet.
– Thomas
Mar 2 at 10:18