require(vendor/autoload.php): failed to open stream

21down votefavorite

6

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:\xampp\htdocs\site_web\send_mail.php on line 3

Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\site_web\send_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

).

So, I looked for this file using: dir /s autoload.php in the Windows command line, and found one here: C:\Windows\SysWOW64\vendor\autoload.php,

but for me, syswow64 folder has nothing to see with autoload.php, I don't see what I am missing here.

Thanks

composer-php phpmailer

shareimprove this question

edited Dec 18 '16 at 15:01

asked Dec 18 '16 at 14:33

adrTuIPKJ44

138117

  • 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

add a comment

11 Answers

activeoldestvotes

up vote43down voteaccepted

What you're missing is running composer install, which will import your packages and create the vendor folder, along with the autoload script.

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.

The autoload.php you found in C:\Windows\SysWOW64\vendor\autoload.php is probably a global composer installation - where you'll usually put things like phpcs, phpunit, phpmd etc.

shareimprove this answer

edited Dec 18 '16 at 19:43

answered Dec 18 '16 at 15:01

Synchro

16.2k85071

  • 1

    How do I run composer install? It's not recognised as a command – Yvonne Aburrow Mar 16 '17 at 9:41

  • 2

    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

  • 1

    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

  • 1

    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

show 3 more comments

 

up vote8down vote

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.

shareimprove this answer

answered Nov 27 '17 at 17:17

mbouzahir

659714

add a comment

up vote5down vote

@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

shareimprove this answer

answered Jan 28 at 14:26

mcmacerson

325139

add a comment

up vote3down vote

Proper autoload.php configuration:

A) Quick answer:

Your autoload.php path is wrong. ie. C:\Windows\SysWOW64\vendor\autoload.php To date: you need to change it to: C:\Users\\vendor\autoload.php


B) Steps with example: We will take facebook/php-graph-sdk as an example; change to Package Name as needed.

  1. Install composer.exe
  2. Open CMD Prompt.  + R + type CMD
  3. Run This command: composer require facebook/graph-sdk
  4. Include path in your PHP page: require_once 'C:\Users\\vendor\autoload.php';
  5. Define configuration Secrets and Access Token for your package...etc.
  6. Happy codinig.

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\\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\\vendor\autoload.php'; 

Find your windows username under C:\Users\

Before all this, as pointed before in B) , you need to run this command:

composer require 

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.

shareimprove this answer

answered Nov 2 '17 at 20:32

wpcoder

448310

add a comment

up vote2down vote

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:

ErrorException ZipArchive::extractTo...

That error is because your path is too much long, I changed to:

C:/xampp5.0/htdocs/p-symfony/*

and worked!

shareimprove this answer

edited Aug 22 '17 at 14:21

answered Jun 13 '17 at 18:05

jjoselon

503214

add a comment

up vote0down vote

First make sure you have installed the composer.

composer install

If you already have installed then update the composer.

update composer

shareimprove this answer

edited Apr 28 at 8:31

Community♦

11

answered Apr 26 at 14:25

IsharaNW

111

  • 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

add a comment

up vote0down vote

I was able to resolve by removing composer and reinstalling the proper way. Here is what I did:

  • sudo apt remove composer
  • sudo apt autoclean && sudo apt autoremove
  • Installed globally with the instructions from: https://getcomposer.org/doc/00-intro.md Download from: https://getcomposer.org/installer global install: mv composer.phar /usr/local/bin/composer (Note: I had to move mine to mv composer.phar /usr/bin/composer)

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

shareimprove this answer

answered May 18 at 18:44

nwolybug

320212

add a comment

up vote-1down vote

run composer update. That's it

shareimprove this answer

answered Dec 20 '17 at 9:38

Bashir ahmad

6010

  • 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

add a comment

up vote-1down vote

Change the auto_prepend_file property on php.ini

; Automatically add files before PHP document. 
;http://php.net/auto-prepend-file 
auto_prepend_file =

shareimprove this answer

answered Feb 19 at 7:37

ercvs

389

  • 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

add a comment

up vote-1down vote

Only this: composer require symfony/finder

shareimprove this answer

answered Apr 12 at 11:50

Ramus B

1

  • Provide more details on your answer to better understand – user9405863 Apr 12 at 11:56

add a comment

up vote-1down vote

***PHP Warning: require_once(C:\xampp\htdocs\test1/bootstrap/app.php): failed to open stream: No such file or directory in C:\xampp\htdocs\test1\artisan on line 20 Warning: require_once(C:\xampp\htdocs\test1/bootstrap/app.php): failed to open stream: No such file or directory in C:\xampp\htdocs\test1\artisan on line 20 PHP Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\test1/bootstrap/app.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\test1\artisan on line 20

Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\test1/bootstrap/app.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\test1\artisan 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.

shareimprove this answer

edited Jul 1 at 2:58

answered Jul 1 at 2:18

Ajmal C

12

add a comment

Your Answer

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

 

Sign up or log in

 Sign up using Google

 Sign up using Facebook

 Sign up using Email and Password

 

Post as a guest

Name

Email

Post Your Answer

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.

Not the answer you're looking for? Browse other questions tagged composer-php phpmailer or ask your own question.

asked

1 year, 7 months ago

viewed

89,647 times

active

1 month ago

 

Want a php job?

  • Senior ReactJS Developer - Crypto/Trading

    Kraken Bitcoin ExchangeNo office location

    $90K - $130KREMOTE

    phpreactjs
  • Full Stack Developer

    CerosNo office location

    $95K - $115KREMOTE

    javascriptphp

Linked

0

WARNING : require(vendor/autoload.php)

0

Vendor autoload directory error

Related

1

Require_once(Net/URL2.php): failed to open stream: no such file or directory

1

composer autoload.php failed to open stream: no such file or directory

1

Failed opening required '../vendor/autoload.php'

1

Fresh Composer install is giving errors on a new git project cloned

0

phpmailer - vendor/autoload.php issues xampp windows

2

Laravel 5.2 - Error while installing laravel using composer with git bash

-6

Warning message in laravel

0

How to create custom helper file in laravel 5.6?

0

No vendor/autoload.php file in Laravel folder after installation

0

'vendor/autoload.php' errors, composer is installed globally

Hot Network Questions

  • Did Macready pull the trigger on Childs?
  • Why allow convicted criminals to vote?
  • Why would a home seller ask a buyer to offer LESS?
  • Merge double subscripts in macro with second subscript passed as argument
  • How can I ensure my existing lifestyle stays the same if I'm immortal?
  • Using gender specific pronouns for inanimate objects
  • Plausible reason why my time machine can only go back a certain amount of time?
  • How can a rocket go straight up after ignition?
  • Logical reason why dystopian government controls what people wear?
  • Why “modding out the homeomorphism” in the category Top makes no rigorous sense?
  • Conflict of interest as a referee?
  • Why would a flight from North America to Asia sometimes fly over the Atlantic?
  • Quick solutions to a modern warning carved/built onto the surface of the earth for future generations
  • Why Experience Manager need to be installed for the DXA?
  • How to talk to my brother-in-law about my concerns about his intent to propose to his girlfriend?
  • Why so few deaths of Americans in the Bataan Death March?
  • In romance languages, are there examples of male names that derive from female names?
  • Loop Through Variables
  • Does Fireball require a “to hit” roll against target's AC?
  • Are any languages similar enough to be partly understandable?
  • Why do black holes warp spacetime so much more than stars that have the same mass?
  • How do warlocks deal with the Healing Elixir spell, since their spell slots get higher-level as they level up?
  • Does being a top-tier university always imply unhealthy graduate student environments?
  • Where The Sun got hydrogen to work if it is 3rd generation of the stars?

 

你可能感兴趣的:(yii2)