Framework: Class 'Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory' not found

Created on 30 Jun 2016  路  12Comments  路  Source: laravel/framework

Laravel version 5.2.39

Just tried to use Mail::raw(); setup with a mailgun configuraion and the mail works fine and i revice it but i still gets the error any idears to whats missing?

Most helpful comment

It is: https://laravel.com/docs/5.3/requests#psr7-requests

The PSR-7 standard specifies interfaces for HTTP messages, including requests and responses. If you would like to obtain an instance of a PSR-7 request instead of a Laravel request, you will first need to install a few libraries. Laravel uses the Symfony HTTP Message Bridge component to convert typical Laravel requests and responses into PSR-7 compatible implementations:

composer require symfony/psr-http-message-bridge
composer require zendframework/zend-diactoros

All 12 comments

I had this same problem and had to pull in the following package in my compose.json.

"symfony/psr-http-message-bridge": "0.2",

Please read the suggested dependencies printed on the screen on composer install.

Why would the message-bridge be needed for raw mail? It doesn't suggest that at all, also the docs don't mention that?

@barryvdh I doubt it is. I think the error was unrelated.

@GrahamCampbell It's due to the use of Guzzle.

That's not true. I use guzzle to send emails without this dependency. It sounds like the wrong request class is getting resolved by mistake here.

I also had this error: Class 'Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory' not found

Traced back to:
https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php#L1015
...where the HttpFoundationFactory class is used.

At line 17 in this Router class the HttpFoundationFactory class is imported:
"use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;"

But I had to require "symfony/psr-http-message-bridge" first to make it work... is this really a 'suggested' dependency and not a required one?

laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use psr7 bridging features (0.2.*).)

It is suggested indeed after composer install/update. But why is this not a requirement?

It is: https://laravel.com/docs/5.3/requests#psr7-requests

The PSR-7 standard specifies interfaces for HTTP messages, including requests and responses. If you would like to obtain an instance of a PSR-7 request instead of a Laravel request, you will first need to install a few libraries. Laravel uses the Symfony HTTP Message Bridge component to convert typical Laravel requests and responses into PSR-7 compatible implementations:

composer require symfony/psr-http-message-bridge
composer require zendframework/zend-diactoros

Thank's for the clarification!

It is: https://laravel.com/docs/5.3/requests#psr7-requests

The PSR-7 standard specifies interfaces for HTTP messages, including requests and responses. If you would like to obtain an instance of a PSR-7 request instead of a Laravel request, you will first need to install a few libraries. Laravel uses the Symfony HTTP Message Bridge component to convert typical Laravel requests and responses into PSR-7 compatible implementations:
composer require symfony/psr-http-message-bridge
composer require zendframework/zend-diactoros

Thanks, @barryvdh! You saved my day. Now I wonder why it not comes installed with Laravel -> Guzzle by default, or it is another thing at all?

Now, I found an issue.
When testing, I did hardcode the whole path to the file and worked fine. But when put into variables, it couldn麓t find the file, like showing below:

fopen(CNH.pdf): failed to open stream: No such file or directory

Found the __DIR__ method. It gets the path, but still wrong because i麓m inside Lavarels app:

$response = $client->request('POST', 'http://gedocflex.com.br:8003/api/file', [ 'headers' => [ 'Content-Type' => 'multipart/form-data', ], 'multipart' => [ [ 'name' => 'idTematica', 'contents' => '202' ], [ 'name' => 'f', 'contents' => fopen(__DIR__ . $request->file, 'r') ], [ 'name' => 'field1',

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lzp819739483 picture lzp819739483  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

progmars picture progmars  路  3Comments

JamborJan picture JamborJan  路  3Comments