Require_once(Net/URL2.php): failed to open stream: no such file or directory

你说的曾经没有我的故事 提交于 2019-12-11 04:24:01

问题


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:

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

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.


回答1:


You need HTTP_Request2 from git master, because it has not been released/tagged yet at the time of writing.




回答2:


This should work:

composer require pear/http_request2:2.2.1

By default pear/net_url2 should be installed which has the required URL2.php file (./vendor/pear/net_url2/Net/URL2.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).

Here is a simple PHP command to test this out:

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

Note: The above command should run without any errors.

Related: Errors in the autoloaded HTTP/Request2 code, how to troubleshoot composer?



来源:https://stackoverflow.com/questions/31484814/require-oncenet-url2-php-failed-to-open-stream-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!