Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vendor/autoload.php: failed to open stream

I worked with a project using composer.But when i run the index file,system shows the following error,

Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in D:\xampp\htdocs\instagram_php\index.php on line 5

Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\instagram_php\index.php on line 5

I have installed composer from https://getcomposer.org/. What am doing wrong?

like image 384
Uma Avatar asked Apr 07 '26 00:04

Uma


1 Answers

You are using require_oncewith a relative path. It is possible but there are so many things that can go wrong that I usually avoid it.

Where is the vendorfolder relative to index.php? I recommend using an absolute path. You can use the magic constants to determine it:

require_once(__DIR__ . '/vendor/autoload.php');

NOTE: you can use /.. to go up the directory tree.

NOTE2: __DIR__ requires php 5.3 or higher. You can use dirname(__FILE__) for older versions.

like image 76
Rad80 Avatar answered Apr 08 '26 15:04

Rad80



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!