postmark-php icon indicating copy to clipboard operation
postmark-php copied to clipboard

Significant Re-Organisation and Modernisation for 5.0 Release

Open gsteel opened this issue 2 years ago • 0 comments

Hi There,

I use the Postmark PHP library in a lot of projects which I've recently migrated to PHP 8.1.

Because of the invalid PHP version constraint in composer.json, this has introduced a lot of runtime errors that could have been avoided by limiting installation to tested versions of PHP.

Not content with downgrading to an older version of PHP, I've updated this library significantly to suit my needs.

There are a number of BC breaks and reviewing this is going to be a fair bit of work, but I'll do my best to summarise the changes:

  • Minimum version of PHP is now 7.4
  • Removes Circle CI configuration in favour of GitHub Actions
  • Supported PHP versions 7.4, 8.0, 8.1
  • CI Tests on "8.2" or nightly
  • Adopted the Doctrine Coding Standard to keep code consistent using PHP Code Sniffer
  • Adds Psalm for static analysis and vastly increased type safety
  • Replaces all existing tests with Unit tests that do not hit the network at all, only verifying the path, method and parameters sent to the remote API (There's a lot of scope here to improve the runtime validation of parameters)
  • All code paths covered by tests
  • Upgraded PHP Unit to the most recent version
  • Drop Guzzle as a dependency and replaces with PSR-18 client dependency and PSR-17 factories. Users will need to install, or already have a PSR-18 client installed in their project in order to use the client. Common clients like Guzzle, and php-http/curl-client all implement the PSR-18 interfaces and provide PSR-17 implementations.
  • Parameter and return type hints have been added, where possible throughout and strict_types enabled
  • Deprecated AdminClient methods have been dropped
  • The primary method names and parameter names and values for the clients have been preserved - in the case of the standard client, the methods have been split out into traits containing related methods to reduce the unwieldy size of the class.
  • Exceptions have been completely re-worked. The previous concrete exception \Postmark\Models\PostmarkException has been replaced with an interface \Postmark\Exception\PostmarkException and there are a number of newly introduced types that implement this interface

Sorry this is such a large pull request, but due to how long other pull requests have been hanging around, I've got my own fork into a position where it can be released and used on >= 8.0 without runtime errors.

gsteel avatar Feb 18 '22 13:02 gsteel