drewm / mailchimp-api

Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP
MIT License
1.99k stars 505 forks source link

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

Open drewm opened 7 years ago

drewm commented 7 years ago

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 commented 7 years ago

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

turigeza commented 7 years ago

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.