Closed dfrozenprogrammer closed 6 years ago
The error message tells you what to do. Just install guzzlehttp/psr7. Or zendframework/diactoros.
its just saying that no stream factories are found . and according to the error its saying to either use guzzle or diactoros .
Also having the same problem, after installing psr/http-message via composer, the error still exists.
Please make sure to run the following command to fix the issue
$ composer require guzzlehttp/psr7 psr/http-message
I've ran both of those commands, however the problem still exists.
What error message do you get?
: No stream factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.
This same as the OP. This was after running the two commands you provided.
@aalicki, installing those dependencies should have fixed the problem. What was the output after you ran the composer command?
Composer reported that those libs were installed properly, and I can verify they exist within the /vendors directory.
The exact error (now different after re-installing the Guzzle and PSR packages:
Type: InvalidArgumentException
Message: Invalid resource type: object
File: /websites/carrepair.com/vendor/guzzlehttp/psr7/src/functions.php
Line: 116
@aalicki, what's your code look like where this fails? Possibly related to https://github.com/guzzle/guzzle/issues/814?
Here is the code with the issues. I checked into guzzle/guzzle#814, but didn't see much relation.
# Instantiate the client.
$mgClient = new Mailgun('xxxxxx');
$domain = "xxxxxxx";
# Make the call to the client.
$mgClient->sendMessage("$domain",
array('from' => 'Mailgun Sandbox <postmaster@xxxxxx>',
'to' => 'Adam <adam@xxxxxx>',
'subject' => 'Contact Request',
'text' => 'Sample email text'));
If you have the latest version of composer, and you have been running this command:
composer require mailgun/mailgun-php php-http/curl-client guzzlehttp/psr7 php-http/message
... and you still get an error message complaining about the stream factories ("No stream factories found.") Then is the only think I can think of now is that you are not using the composer autoloader. Is that right?
@aalicki could you update the feedback for this issue? So devs knows about if it is still a problem or they could close it. If not probably will be closed by inactivity at some point
I think the issue still stands, I am using PHP 7.0.8 AND Code-igniter 3.1.6 and encounters the same issue.
Error looks like:
files in root_dir > application > vendor
looks like
I installed the following libraries via composer
Note: when I try to install above libs composer there's nothing to install or update.
My Controller looks like:
require '../vendor/autoload.php';
use Mailgun\Mailgun;
class CartU extends User_Controller
{
/**
* CartU constructor.
*/
public function __construct()
{
parent::__construct();
// $this->data['user']['head']['pageLevelPlugins']['css'] = [];
$this->data['user']['foot']['pageLevelPlugins']['js'] = [];
$this->data['user']['page_js'] = 'cart/user-js';
//$this->load->model('Dress_categories_m', 'dc', TRUE);
$this->load->library('my_encrypt');
}
public function cartMail()
{
# Instantiate the client.
$mgClient = new Mailgun('key-381e75f9e099ae4786faa32cf259f539');
$domain = "rs2a246a80c26d44c7b2d4a16a4fb999cc.mailgun.org";
# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
'from' => 'Excited User <mailgun@knblogodesign.com>',
'to' => 'Daniyal <dani.0332@gmail.com>',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomness!'
));
}
}
Hey @dani0332
SDK have had a few changes, can you please confirm the current installed version?
composer show mailgun/*
Cheers,
As the exception says, you are missing a PSR7 implementation. Try installing guzzlehttp/psr7.
Also see: http://docs.php-http.org/en/latest/discovery.html#common-errors
@DavidGarciaCat,
it says mailgun/mailgun-php 2.3.4 The Mailgun SDK provides methods for all API functions.
@Nyholm
After running composer require guzzlehttp/psr7
I got:
Using version ^1.4 for guzzlehttp/psr7
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
My composer.json file looks like:
{
"description": "The CodeIgniter framework",
"name": "codeigniter/framework",
"type": "project",
"homepage": "https://codeigniter.com",
"license": "MIT",
"support": {
"forum": "http://forum.codeigniter.com/",
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
"slack": "https://codeigniterchat.slack.com",
"source": "https://github.com/bcit-ci/CodeIgniter"
},
"require": {
"php": ">=7.0.8",
"mailgun/mailgun-php": "^2.3",
"php-http/guzzle6-adapter": "^1.1",
"php-http/message": "^1.6",
"guzzlehttp/psr7": "^1.4",
"php-http/curl-client": "^1.7"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*",
"phpunit/phpunit": "4.* || 5.*"
}
}
Great. Im happy it worked out for you.
Hey @dani0332
Please consider to use the new way offered by this SDK to make your API calls, the method that you are using is flagged as deprecated:
$mailgun = Mailgun::create('your API key goes here's);
$mailgun->messages()->send(
'domain',
[
'argumentKey' => 'argumentValue',
]
);
Mailgun::create('your API key goes here');
Mobile spell checker added the final s
, please ignore it
@Nyholm I never said it worked out, the error still as it was at the start.
@DavidGarciaCat I updated my method like this (but still the same error).
public function cartMail()
{
$apiKey = "API KEY";
$domain = "DOMAIN";
$mailgun = Mailgun::create($apiKey);
$mailgun->messages()->send(
$domain,
[
'from' => 'Excited User <mailgun@knblogodesign.com>',
'to' => 'Daniyal <dani.0332@gmail.com>',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomness!'
]
);
}
Hey @dani0332
Based on the screenshot you added, the php-http/message
should be installed
However I can see it is already on your composer.json
file so:
1) Can you please confirm it was installed and what version?
composer show php-http/*
2) Can you please provide an up-to-date backtrace of the error, now that you are using the new method provided by the SDK?
After running: composer show php-http/*
I got:
php-http/client-common 1.7.0 Common HTTP Client implementations and tools for HTTPlug
php-http/curl-client v1.7.0 cURL client for PHP-HTTP
php-http/discovery 1.3.0 Finds installed HTTPlug implementations and PSR-7 message factories
php-http/guzzle6-adapter v1.1.1 Guzzle 6 HTTP Adapter
php-http/httplug v1.1.0 HTTPlug, the HTTP client abstraction for PHP
php-http/message 1.6.0 HTTP Message related tools
php-http/message-factory v1.0.2 Factory interfaces for PSR-7 HTTP Message
php-http/multipart-stream-builder 1.0.0 A builder class that help you create a multipart stream
php-http/promise v1.0.0 Promise used for asynchronous HTTP requests
The Error BackTrace looks like:
I realized I had two vendor folders
root_dir > application > vendor
root_dir > vendor
So, I moved (merged) vendor folder out from root_dir > application > vendor
to root_dir > vendor
After that I Re-run my version commands you asked for:
E:\xampp\htdocs\darzee>composer show mailgun/*
mailgun/mailgun-php v2.4.0 The Mailgun SDK provides methods for all API functions.
E:\xampp\htdocs\darzee>composer show php-http/*
php-http/client-common 1.7.0 Common HTTP Client implementations and tools for HTTPlug
php-http/curl-client v1.7.0 cURL client for PHP-HTTP
php-http/discovery 1.3.0 Finds installed HTTPlug implementations and PSR-7 message factories
php-http/guzzle6-adapter v1.1.1 Guzzle 6 HTTP Adapter
php-http/httplug v1.1.0 HTTPlug, the HTTP client abstraction for PHP
php-http/message 1.6.0 HTTP Message related tools
php-http/message-factory v1.0.2 Factory interfaces for PSR-7 HTTP Message
php-http/multipart-stream-builder 1.0.0 A builder class that help you create a multipart stream
php-http/promise v1.0.0 Promise used for asynchronous HTTP requests
Which in-turn change the error to:
And for ref. my controller class looks like this:
require '../vendor/autoload.php';
use Mailgun\Mailgun;
class CartU extends User_Controller
{
public function __construct()
{
parent::__construct();
// $this->data['user']['head']['pageLevelPlugins']['css'] = [];
$this->data['user']['foot']['pageLevelPlugins']['js'] = [];
$this->data['user']['page_js'] = 'cart/user-js';
//$this->load->model('Dress_categories_m', 'dc', TRUE);
$this->load->library('my_encrypt');
}
public function cartMail()
{
$apiKey = "API KEY";
$domain = "Domain Name";
$mailgun = Mailgun::create($apiKey);
$mailgun->messages()->send(
$domain,
[
'from' => 'Excited User <mailgun@knblogodesign.com>',
'to' => 'Daniyal <dani.0332@gmail.com>',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomness!'
]
);
}
}
Hey @Nyholm
Is there any known issue with the SSL connection? Potential issue with local config maybe?
Not as far as I know. But Windows, PHP and SSL is usually an issue...
I am getting this error as well. Shouldn't Mailgun include all required packages via Composer?
@dani0332
You need default SSL cert, follow this guide - https://stackoverflow.com/questions/29822686/curl-error-60-ssl-certificate-unable-to-get-local-issuer-certificate
And DO NOT combine the Code Igniter Composer (root/composer.json & root/vendor) with the applications Composer (root/application/composer.json & root/application/vendor) as these are designed to be seperate.
Hey there,
Mailgun uses virtual packages as described on the Readme file, so you should follow the install steps like any other vendor package.
Are you getting an error if you install all of them?
@DavidGarciaCat I was able to get it working properly after installing all the necessary packages. I have never really worked with Guzzle personally so have no idea what the normal protocol is for that. However, this thread helped out a lot.
I guess I missed the install steps like a few others but thanks for your help and clarifications
Hi @MeekLogic
Could you please include the steps that you did? If we're missing anything in our README then we can add it.
Thanks,
@DavidGarciaCat – Well in this thread there were two issues.
Missing Composer Dependencies
No stream factories found. To use Guzzle...
and No uri factories found. To use Guzzle...
Taken from the require-dev within composer.json
Curl for PHP on Windows (which is used by the Guzzle library) needs a default root certificate
cURL error 60: SSL certificate: unable to get local issuer certificate...
Followed the directions from top solution in this link – https://stackoverflow.com/questions/29822686/curl-error-60-ssl-certificate-unable-to-get-local-issuer-certificate
Hi @MeekLogic
Please refer to the Installation notes where you will read this:
The Mailgun api client is not hard coupled to Guzzle or any other library that sends HTTP messages.
And this:
Mailgun has a dependency on the virtual package php-http/client-implementation which requires you to install an adapter
As pointed on installation steps:
If you just want to get started quickly you should run the following command:
php composer.phar require mailgun/mailgun-php php-http/curl-client guzzlehttp/psr7
The whole installation process has been tested and verified on this Issue https://github.com/mailgun/mailgun-php/issues/429#issuecomment-358316771
I must assume that the installation steps were not followed as described on the README file, so this is not an issue. My tests on the other issue are an example of this.
"Read the docs!"
As @Nyholm pointed on his comment here https://github.com/mailgun/mailgun-php/issues/143#issuecomment-356865905
Windows, PHP and SSL is usually an issue...
If you have time to send a PR with a fix for this case, we're more than happy to review and merge.
@DavidGarciaCat – Did I misunderstand something here or did you?
I have already acknowledged skipping over the installation of Guzzle and solved my issues as posted above on 1/16/2018.
Your comment above was of no help to me and a bit insulting given I had already told you beforehand that I had solved my issues. Maybe you didn't mean to actually reply to me but just state it to everyone who visits this thread?
The only reason I reiterated over the stumbling I encountered and how I was able to get past that was because you specifically asked me too.
"Get your shit together!"
Hey @MeekLogic - Sorry if that offended you, it was not my intention. I guess it was a misunderstanding, written answers are usually not helping to understand the tone or the intention.
@DavidGarciaCat – I agree that written text can be troublesome (albeit having it's pluses as well) and very much appreciate your apology. There are no hard feelings. :thumbsup:
Hi, @joeleonjr
I cannot see any comment including an API key, after reviewing the comments twice (from my phone).
Please kindly point out the comment so the user who posted it can review it and rotate the keys of needed.
Thanks,
👍 @dani0332 you might want to check your key - revoke that one and get a new pair seems the best course of action, indeed.
when i am trying to send a mail using the 2.1.1 version of mailgun api i get this particular error :- : No stream factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation. please tell me if any one has a solution for this .