SparkPost / php-sparkpost

SparkPost client library for PHP
https://www.sparkpost.com/
MIT License
195 stars 91 forks source link

TypeError Ivory\HttpAdapter\HttpAdapterInterface instead Http\Adapter\Guzzle6\Client #163

Closed cba85 closed 7 years ago

cba85 commented 7 years ago

Hello,

I have a problem with this package.

I obtain this error :

 Fatal error: Uncaught TypeError: Argument 1 passed to SparkPost\SparkPost::setHttpAdapter() must be an instance of Ivory\HttpAdapter\HttpAdapterInterface, instance of Http\Adapter\Guzzle6\Client given, called in /vendor/sparkpost/php-sparkpost/lib/SparkPost/SparkPost.php on line 55 and defined in /vendor/sparkpost/php-sparkpost/lib/SparkPost/SparkPost.php on line 116

I use PHP 7.1.0.

I use these packages:

"guzzlehttp/guzzle": "^6.2",
"php-http/guzzle6-adapter": "^1.1",
"sparkpost/sparkpost": "^2.1"

I use your example code (with my Sparkpost API key):

<?php
require 'vendor/autoload.php';

use SparkPost\SparkPost;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$httpClient = new GuzzleAdapter(new Client());
$sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
?>

Can you help me?

avigoldman commented 7 years ago

Hey @cba85 sorry about the late response. It looks like you are using a 1.x version of the library where we used the Ivory Adaptor. In the 2.x version we moved to httplug. I think you could just update to the latest version of the php sparkpost library and you should be good to go.

cba85 commented 7 years ago

Hello, You are completely right, an update fixed my problem. Thank you a lot !