laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.54k stars 11.02k forks source link

Class 'Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory' not found #14180

Closed stefanoruth closed 8 years ago

stefanoruth commented 8 years ago

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?

base-zero commented 8 years ago

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

"symfony/psr-http-message-bridge": "0.2",
GrahamCampbell commented 8 years ago

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

barryvdh commented 8 years ago

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

GrahamCampbell commented 8 years ago

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

base-zero commented 8 years ago

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

GrahamCampbell commented 8 years ago

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.

ametad commented 8 years ago

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?

ametad commented 8 years ago

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?

barryvdh commented 8 years ago

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

ametad commented 8 years ago

Thank's for the clarification!

marcellopato commented 5 years ago

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

marcellopato commented 5 years ago

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',

amidesfahani commented 3 years ago

problem still exists. i've tried to install required packages and fresh install of laravel 8. still says: Class "Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory" not found

PMessinezis commented 3 years ago

Try:
composer require symfony/psr-http-message-bridge