Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find HTTP/Request2.php #11

Open
Rudloff opened this issue Sep 19, 2016 · 7 comments
Open

Can't find HTTP/Request2.php #11

Rudloff opened this issue Sep 19, 2016 · 7 comments
Assignees

Comments

@Rudloff
Copy link

Rudloff commented Sep 19, 2016

Hello,

I installed your library with Composer. I get this error when trying to run it:

PHP Warning:  require_once(HTTP/Request2.php): failed to open stream: No such file or directory in /home/pierre/www/openvegemap/vendor/kenguest/services-openstreetmap/Services/OpenStreetMap.php on line 19
PHP Fatal error:  require_once(): Failed opening required 'HTTP/Request2.php' (include_path='/home/pierre/www/openvegemap/vendor/pear/pear_exception:/home/pierre/www/openvegemap/vendor/pear/log:/home/pierre/www/openvegemap/vendor/kenguest/services-openstreetmap:.:/usr/share/php:/usr/share/pear') in /home/pierre/www/openvegemap/vendor/kenguest/services-openstreetmap/Services/OpenStreetMap.php on line 19

Here is my code:

<?php
require_once 'vendor/autoload.php';
$osm = new Services_OpenStreetMap();
@Rudloff
Copy link
Author

Rudloff commented Sep 19, 2016

Note that it works if I install http_request2 with PEAR. But I think Composer should be able to autoload it without having to use PEAR.

@kenguest kenguest self-assigned this Sep 19, 2016
@kenguest
Copy link
Member

This install and demo works for me. What version did you try to install?

vagrant@vagabond:/osm$ cat > composer.json
{
"require": {
"kenguest/services-openstreetmap": "*"
}
}
vagrant@vagabond:
/osm$ composer update
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Installing pear/pear_exception (v1.0.0)
    Loading from cache
  • Installing pear/log (1.12.9)
    Loading from cache
  • Installing pear/net_url2 (v2.2.1)
    Loading from cache
  • Installing pear/http_request2 (v2.2.1)
    Loading from cache
  • Installing kenguest/services-openstreetmap (V0.5.0)
    Loading from cache

pear/log suggests installing pear/db (Install optionally via your project's composer.json)
kenguest/services-openstreetmap suggests installing pear/cache (*)
Writing lock file
Generating autoload files
vagrant@vagabond:~/osm$ cat > f.php

getNode(545109)->getUser()); vagrant@vagabond:~/osm$ php f.php string(5) "izzor" vagrant@vagabond:~/osm$

@Rudloff
Copy link
Author

Rudloff commented Sep 20, 2016

I installed 0.5.0.
Are you sure in your case the library is loaded from vendor/pear/http_request2/HTTP/Request2/ and not /usr/share/php/HTTP/Request2/?

@FireLizard
Copy link
Contributor

It seems you have to add the following line to your composer.json to get HTTP/Request2 auto-loaded:
"include-path": [ "vendor/pear/http_request2" ]

(But that is just a workaround)

@sascha-hendel
Copy link
Contributor

I had the same problem, and found this workaround (the methods mentioned here haven't worked for me):
Switch to directory ~/vendor/kenguest/services-openstreetmap and create a symboli link
ln -s ../../pear/http_request2/HTTP HTTP

@winternet-studio
Copy link

I solved this by adding this line

set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ .'/vendor/pear/http_request2');

before $osm = new Services_OpenStreetMap();

But then I ran into an issue with http now redirecting to https - and even manually changing to https in the config file it still had an issue (though that could potentially just be on my local dev machine). Realized it was probably just as easy to use the API directly as describe at https://wiki.openstreetmap.org/wiki/API_v0.6#API_calls

@sad-spirit
Copy link
Member

HTTP_Request2 2.4+ no longer sets include_path when installed with composer. The suggested approach is to conditionally include the file if autoloading does not work (this will work with PEAR installation, composer installation and even mix of those):

if (!class_exists('HTTP_Request2', true)) {
    require_once 'HTTP/Request2.php';
}

See also pear/HTTP_Request2#18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants