本文介绍了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'
(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";'

相关:

这篇关于Require_once(Net / URL2.php):无法打开流:没有此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 05:41