Require_once(Net / URL2.php):无法打开流:没有此类文件或目录

Require_once(Net / URL2.php):无法打开流:没有此类文件或目录

问题描述:

我在项目中使用Composer安装了 pear / http_request2 版本 2.2.1 ,但是当我尝试发出我的第一个请求时,出现此警告和致命错误:

I installed the pear/http_request2 version 2.2.1 using Composer in my project but when I am trying to make my first request I am getting this Warning and Fatal error:


警告:require_once(Net / URL2.php):无法打开流:
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
在第24行上没有这样的
文件或目录

Warning: require_once(Net/URL2.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php on line 24

严重错误:require_once():无法打开所需的'Net / URL2.php'
(include_path ='/ Applications / XAMPP / xamppfiles / htdocs / jet / vendor / pear / pear_exception :。:/ Applications / XAMPP / xamppfiles / lib / php')

中/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
在第24行上

Fatal error: require_once(): Failed opening required 'Net/URL2.php' (include_path='/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/pear_exception:.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php on line 24

感谢您提供任何有关修复方法的帮助。

I appreciate any help on how to fix it, thanks in advance.

David。

这应该有效:

composer require pear/http_request2:2.2.1

默认情况下 pear / net_url2 应该安装有必需的 URL2.php 文件( ./ vendor / pear / net_url2 / Net / URL2.php )。

By default pear/net_url2 should be installed which has the required URL2.php file (./vendor/pear/net_url2/Net/URL2.php).

然后确保您包含 vendor / autoload.php 文件在脚本中自动加载包含路径(请参见: vendor / composer / include_paths.php 文件)。

Then make sure you're including vendor/autoload.php file in your scripts to load automatically the include paths (see: vendor/composer/include_paths.php file).

这是一个简单的PHP命令来进行测试:

Here is a simple PHP command to test this out:

php -r 'require_once "vendor/autoload.php"; require_once "Net/URL2.php";'

注意:上面的命令应在没有

相关:自动加载的HTTP / Request2代码,如何对作曲家进行故障排除?