我使用 composer 处理一个项目。但是当我运行索引文件时,系统显示以下错误,
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
我已经从 https://getcomposer.org/ 安装了 composer . 哪里做错了?
最佳答案
您正在使用具有相对路径的 require_once
。这是可能的,但有太多可能出错的地方,我通常会避免它。
相对于 index.php
的 vendor
文件夹在哪里?我建议使用绝对路径。您可以使用魔术常量来确定它:
require_once(__DIR__ . '/vendor/autoload.php');
注意:您可以使用/..
向上移动目录树。
注意 2:__DIR__
需要 php 5.3 或更高版本。对于旧版本,您可以使用 dirname(__FILE__)
。
关于php - 供应商/autoload.php : failed to open stream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44623636/