mailgun/mailgun-php

DiscoveryFailedException: Could not find resource using any discovery strategy

stccorp opened this issue · 1 comments

I use the example code from mailgun
composer.json
{
"require": {
"mailgun/mailgun-php": "3.5.2"
}
}

test.php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
$mg = Mailgun::create('my- key-here'); // For US servers

$mg->messages()->send('my-domain-here', [
'from' => 'bob@example.com',
'to' => 'sally@example.com',
'subject' => 'The PHP SDK is awesome!',
'text' => 'It is so simple to send a message.'
]);

Error:

PHP Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors

  • No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
  • No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Phalcon\Http\Message\UriFactory, Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\UriFactory, GuzzleHttp\Psr7\HttpFactory, Http\Factory\Diactoros\UriFactory, Http\Factory\Guzzle\UriFactory, Http\Factory\Slim\UriFactory, Laminas\Diactoros\UriFactory, Slim\Psr7\Factory\UriFactory.

in /root/mailgun/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41
Stack trace:
#0 /root/mailgun/vendor/php-http/discovery/src/ClassDiscovery.php(85): Http\Discovery\Exception\DiscoveryFailedException::create()
#1 /root/mailgun/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php(117): Http\Discovery\ClassDiscovery::findOneByType()
#2 /root/mailgun/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php(134): Http\Discovery\Psr17FactoryDiscovery::findUriFactory()
#3 /root/mailgun/vendor/mailgun/mailgun-php/src/HttpClient/HttpClientConfigurator.php(114): Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()
#4 /root/mailgun/vendor/mailgun/mailgun-php/src/HttpClient/HttpClientConfigurator.php(70): Mailgun\HttpClient\HttpClientConfigurator->getUriFactory()
#5 /root/mailgun/vendor/mailgun/mailgun-php/src/Mailgun.php(63): Mailgun\HttpClient\HttpClientConfigurator->createConfiguredClient()
#6 /root/mailgun/vendor/mailgun/mailgun-php/src/Mailgun.php(74): Mailgun\Mailgun->__construct()
#7 /root/mailgun/test.php(14): Mailgun\Mailgun::create()
#8 {main}

Forgot to read the instructions and include symfony/http-client nyholm/psr7