Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Guzzle with any HttpClient #3

Open
tacman opened this issue Aug 24, 2024 · 2 comments
Open

Replace Guzzle with any HttpClient #3

tacman opened this issue Aug 24, 2024 · 2 comments

Comments

@tacman
Copy link

tacman commented Aug 24, 2024

The library has a hard dependency on Guzzle 7. My application only uses Symfony's HttpClient (which rocks). Instead of requesting that you use my favorite client, the most flexible way is to allow any psr7 client. For example, here's the meilisearch library documentation.

🔧 Installation

You will need to install packages that "provide" psr/http-client-implementation and psr/http-factory-implementation.

A list with compatible HTTP clients and client adapters can be found at php-http.org.

If you don't know which HTTP client to use, we recommend using Guzzle 7:

composer require meilisearch/meilisearch-php guzzlehttp/guzzle http-interop/http-factory-guzzle:^1.0

Here is an example of installation with the symfony/http-client:

composer require meilisearch/meilisearch-php symfony/http-client nyholm/psr7:^1.0

💡 More HTTP client installations compatible with this package can be found in this section.

From https://github.com/meilisearch/meilisearch-php?tab=readme-ov-file#-installation

I think this is the best approach, although I forget how psr-18 fits in. Anyway, when Symfony's HTTP client is used in a symfony project, the requests are automatically logged to the debug toolbar, which I love.

I'm toying with creating a Symfony bundle that wraps around this library (which standardizes the API key in an environment variable and makes it easier to inject the class with the key already set).

@SebaOfficial
Copy link
Owner

Hello, could you provide a more practical example by making a PR?

@tacman
Copy link
Author

tacman commented Aug 24, 2024

Alas, I did it once, using the http-discovery, and now I can't find where! I'll keep an eye out, though, it's a trend to move away from Guzzle as a hard requirement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants