No PSR-17 request factory found on exchanger instantiation
f-liva opened this issue · comments
$exchanger = new \Exchanger\Service\ExchangeRatesApi();
I got this error:
No PSR-17 request factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation
I don't understand why.
Have you done installation procedure in your project ?
Yes, same issue with:
$client = new Http\Client\Curl\Client();
$exchanger = new Exchanger\Service\ExchangeRatesApi($client);
For me it is working, doing the following :
mkdir test && cd test
composer require php-http/curl-client nyholm/psr7 php-http/message florianv/exchanger
Then i created a test.php
file :
<?php
include "vendor/autoload.php";
$exchanger = new \Exchanger\Service\ExchangeRatesApi();
var_dump($exchanger);
I do get an exchanger instance when i run the script.
php test.php
output :
me@host:~/projects/test$ php test.php
object(Exchanger\Service\ExchangeRatesApi)#3 (3) {
["httpClient":"Exchanger\Service\HttpService":private]=>
object(Http\Client\Curl\Client)#2 (5) {
["curlOptions":"Http\Client\Curl\Client":private]=>
array(3) {
[52]=>
bool(false)
[42]=>
bool(false)
[19913]=>
bool(false)
}
["responseFactory":"Http\Client\Curl\Client":private]=>
object(Nyholm\Psr7\Factory\Psr17Factory)#4 (0) {
}
["streamFactory":"Http\Client\Curl\Client":private]=>
object(Nyholm\Psr7\Factory\Psr17Factory)#5 (0) {
}
["handle":"Http\Client\Curl\Client":private]=>
NULL
["multiRunner":"Http\Client\Curl\Client":private]=>
NULL
}
["requestFactory":"Exchanger\Service\HttpService":private]=>
object(Nyholm\Psr7\Factory\Psr17Factory)#6 (0) {
}
["options":protected]=>
array(0) {
}
}
@fede91it You need to install a package from the list, as stated in the error, for example nyholm/psr7
.
Installing nyholm/psr7 it worked, sorry and thank you