mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

Error "Class "GuzzleHttp\ClientInterface" not found" - in production #710

Closed yachtino-dev closed 6 months ago

yachtino-dev commented 7 months ago

Specifications

Describe the issue

I integrated Mollie payments in my project (no framework, own programming). In my composer.json is:

"require": {
    "php": ">=8.0 <9",
    ...
    "mollie/mollie-api-php": "^2.66",
},

No require-dev.

On production server I get error: Class "GuzzleHttp\ClientInterface" not found (file GuzzleHttp/ClientInterface.php). Comming from: /vendor/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterPicker.php(45): interface_exists('\\GuzzleHttp\\ClientInterface')

In Mollie, the dependency of Guzzle is only in require-dev. Why it is required in production? What helped was that I added Guzzle to my own composer.json, so the class is loaded. Is it not a bug?

sandervanhooft commented 7 months ago

Hi @yachtino-dev,

Thanks for reaching out.

The package is detecting whether Guzzle is present, and should fall back to curl if it isn't.

We've had a hard Guzzle dependency in the past, but it collided with lots of other frameworks and setups having Guzzle already present.

Is curl available in your system if you do not pull in Guzzle?

yachtino-dev commented 6 months ago

Yes, our productive system has curl 7.64.0 installed.

sandervanhooft commented 6 months ago

Thanks @yachtino-dev .

We will try to reproduce the issue here, keeping this ticket open for reference.

Naoray commented 6 months ago

Hi @yachtino-dev,

in order to reproduce this issue I'd need more information about your server or the project setup in general.

Normally the interface_exists() shouldn't throw a file not found exception...

yachtino-dev commented 6 months ago

Hi @Naoray, thank you. That was the right hint. You are right, the exception should not have been thrown. That was my special autoloader. Is fixed now. Sorry for the inconveniences. You can delete/close this thread.

Naoray commented 6 months ago

@yachtino-dev glad you figured it out!