[英]Failed to open stream: No such file or directory, when using __DIR__
PHP is throwing this error when trying to access autoload: require_once __DIR__. '/../vendor/autoload.php';
PHP 在尝试访问自动加载时抛出此错误:
require_once __DIR__. '/../vendor/autoload.php';
require_once __DIR__. '/../vendor/autoload.php';
Warning: require_once(/Applications/MAMP/htdocs/crud_app/public/vendor/autoload.php): Failed to open stream: No such file or directory in /Applications/MAMP/htdocs/crud_app/public/index.php on line 6
警告:require_once(/Applications/MAMP/htdocs/crud_app/public/vendor/autoload.php):无法打开 stream:/Applications/MAMP/htdocs/crud_app/public/index.ZE1BFD762321E409CEE4AC0B6E8419 第 3 行第 6 行第 3 行没有这样的文件或目录
The thing is that if I echo __DIR__.'/../vendor/autoload.php';
问题是,如果我
echo __DIR__.'/../vendor/autoload.php';
it shows /Applications/MAMP/htdocs/crud_app/public
and the vendor directory is outside of public .它显示
/Applications/MAMP/htdocs/crud_app/public
并且供应商目录在public之外。 This is the path where autoload.php
is:这是
autoload.php
所在的路径:
/Applications/MAMP/htdocs/crud_app/controllers/vendor/autoload.php
Any idea what is happening?知道发生了什么吗? This is my repo in case you want to look at it.
如果您想查看它,这是我的回购。 Running PHP 8.1 and macOS.
运行 PHP 8.1 和 macOS。 Thanks in advance.
提前致谢。
index.php
isn't inside controllers
, you need to add that to the path. index.php
不在controllers
中,您需要将其添加到路径中。
require_once __DIR__ . '/../controllers/vendor/autoload.php';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.