vendor/autoload.php: failed to open stream

2019-04-13 16:27发布

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?

1条回答
我只想做你的唯一
2楼-- · 2019-04-13 17:03

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.

查看更多
登录 后发表回答