composerでHTTP_Request2を入れてみます
composer.json
{
"require": {
"pear/http_request2": "2.2.1"
}
}
$ php composer.phar update
HTTP_Request2を使ってみます
test.php
<?php
require 'vendor/autoload.php';
$request = new HTTP_Request2();
print_r($request);
$ php test.php
php test.php
PHP Warning: require_once(Net/URL2.php): failed to open stream: No such file or directory in /Users/tsukui/Desktop/foo/vendor/pear/http_request2/HTTP/Request2.php on line 24
PHP Fatal error: require_once(): Failed opening required 'Net/URL2.php' (include_path='/Users/tsukui/Desktop/foo/vendor/pear/pear_exception:.:/usr/lib/php/pear') in /Users/tsukui/Desktop/foo/vendor/pear/http_request2/HTTP/Request2.php on line 2
Net_URL2が入っているのに、includeできてないからエラーになっていますね
composer.jsonをこのようにします
composer.json
{
"require": {
"pear/http_request2": "2.2.1"
},
"include-path": [
"vendor/pear/net_url2",
"vendor/pear/http_request2"
]
}
$ php composer.phar update
再実行
$ php test.php
HTTP_Request2 Object
(
[observers:protected] => Array
(
)
中略
[adapter:protected] =>
[cookieJar:protected] =>
)
実行できるようになりました