1

Writing some REST API bits and going to use Guzzle, which I have used many times before.

The issue I am coming across is, I know Guzzle has to take the configuration via parameters when constructing it, but when using dependency injection to instantiate Guzzle in my model, I can't then set the configuration parameters on it.

Whats the best way to handle this?

Thanks

1

1 Answer 1

0

Magento doesn't provide a centralize way to make api REST call to external services.
I worked with lot of customers, developers always use their own REST implementation using multiple libraries like Guzzle, Curl, Zend...

That's why I recommand you to use this module to industialize your REST API call through Guzzle library: https://github.com/zepgram/module-rest

  • Prevent code duplication with a basic implementation in di.xml (only 1 class to create)
  • Centralize all your REST web service under the same configuration
  • Benefits built-in registry and cache system to ensure and secure performance
  • Include a generic logger with a debug mode option to retrieve parameters, request and result
  • Declare your request and result as a json serialized or not, avoiding multiple implementation of the serializer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.