carsdotcom/php-request-class

Structure the logic around Guzzle API requests into object-oriented classes
31,380 2
Install
composer require carsdotcom/php-request-class
Latest Version:v2.0.0
PHP:^8.1
License:MIT
Last Updated:Aug 15, 2026
Links: GitHub  ·  Packagist
Maintainer: jwadhams

php-request-class

Structure the logic around Guzzle API requests into object-oriented classes

What?

We maintain an application that is reliant on dozens of REST APIs, most of which do not have SDKs.

We love Guzzle! But most of the documentation assumes that making a request is "easy," just a few lines of code.

But we've discovered in our own use that the structure around that Guzzle request can run into hundreds of lines, managing pre-requisites like authentication, converting data between our internal types and our partners' types, etc.

So we created AbstractRequest as a standardized way to:

  1. Organize logic into classes.
  2. Provide swappable traits for encoding and decoding (XML, JSON, forms, even simplified GraphQL!)
  3. Log everything using Laravel's File facade
  4. Cache using Laravel's Cache facade (with a simple automatic cache key generator)
  5. Provide a structure for chainable prerequisites (like authentication)
  6. Provide a structure for catching exceptions and parsing responses back into your internal logic
  7. Let you defer decisions about call order or synchronous/asynchronous processing to the user of the request class

Running the Tests

Install the dev dependencies:

composer install

Then run phpunit from the root of the project:

./vendor/bin/phpunit

Related Packages

hannesvdvreken/guzzle-clockwork

A Guzzle middleware that logs requests with Clockwork

58,596 44
kiwilan/php-http-pool

PHP package with easy-to-use GuzzleHttp pool wrapper to make concurrent requests...

2,684 2
hannesvdvreken/guzzle-debugbar

A Guzzle middleware that logs requests to debugbar's timeline

443,551 76
soltancode/send-request

Simple package for Laravel that makes it easy to send HTTP requests and integrat...

2,551 2

Version History

Version Released PHP Laravel License
v2.0.0 ^8.1 ^9.19 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
v1.9.0 ^8.1 ^9.19 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
v1.8.0 ^8.1 ^9.19 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
v1.7.4 ^8.1 ^9.19 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
v1.7.3 ^8.1 ^9.19 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT