mailchimp-api icon indicating copy to clipboard operation
mailchimp-api copied to clipboard

Proposal: replacement of all cURL functionality with injection of HTTPlug instance

Open drewm opened this issue 7 years ago • 2 comments

Most of the complexity and issues around this library are from basic HTTP plumbing. HTTP plumbing should be a solved problem.

I'd be interested in feedback for this proposal for v4 of this library.

  1. Enable the constructor to accept injection of an HTTPlug object to represent an HTTP client library
  2. Remove all raw cURL code from this library, using the HTTP client instead
  3. Bundle an extremely simple HTTPlug-implementing client (ideally pre-existing) to use as a default
  4. Implement a build process for this library to compile all dependancies into a single includable 'dist' file, as a non-composer install option

This enables two usage profiles:

  1. Composer-based ecosystems can install this library, plus their HTTP client dependancy of choice (e.g. Guzzle). In this case we remain very lightweight and simple.
  2. A stand-alone user (simple project, or legacy codebase) can download a single file to include in their project and not worry about the complexity within.

This adds a little bit of build complexity to the project, but would hand off all HTTP duties which are currently the cause of nearly all the issues and complexity in this library.

I'd welcome thoughts and feedback from anyone who uses this library.

drewm avatar Mar 07 '17 16:03 drewm

Note, HTTPlug would require bumping minimum requirements to PHP 5.4, which I think is perfectly acceptable in 2017.

drewm avatar Mar 07 '17 16:03 drewm

It was nice to see that I was not forced to use composer for once 👍 . Just 1 file and job is done. Nice job. I would change the const TIMEOUT = 10; so that one can access it and change it as others suggest in the thread you have referred to above.

turigeza avatar Mar 23 '17 15:03 turigeza