Download the PHP package fofx/guzzle-middleware without Composer
On this page you can find all versions of the php package fofx/guzzle-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fofx/guzzle-middleware
More information about fofx/guzzle-middleware
Files in fofx/guzzle-middleware
Package guzzle-middleware
Short Description Enhanced Guzzle client with middleware, debugging, and proxy support.
License MIT
Informations about the package guzzle-middleware
FOfX Guzzle Middleware
FOfX Guzzle Middleware is an enhanced Guzzle client with middleware, debugging, and proxy support. It provides extended functionality for capturing detailed request and response information, making it easier to debug and log HTTP transactions in your PHP applications.
Features
- Enhanced Guzzle client with middleware support
- Detailed request and response logging
- Debug information capture
- Proxy configuration support
- Easy-to-use interface for making HTTP requests
- Flexible configuration options
Requirements
- PHP 8.1 or higher
- Guzzle 7.9 or higher
Installation
You can install the package via Composer:
Development Server
The package includes a development server for testing and development. Start it before running tests:
The dev server provides endpoints for testing:
/redirect/{n}- Redirects n times/error/{code}- Returns specified HTTP error code/delay/{seconds}- Delays response/api/test- Basic test endpoint/api/echo- Echoes request details
Note: The dev server must be running for unit tests to pass.
Usage
Basic Usage
Here's a simple example of how to use the MiddlewareClient:
This should print each transaction in the redirect chain:
To print just the last transaction, use the getLastTransaction method:
This should print the last transaction.
Note: The elements are named 'request' and 'response' instead of '0', '1', etc.
To print a summary of the transactions, use the getTransactionSummary method:
This should print a summary of the transactions:
To print the Guzzle debug stream, use the getDebug method:
This should print the following:
POST Example
To get the last transaction for a POST request, use the makeRequest method with the POST method:
Using the makeMiddlewareRequest Function
Alternatively, you can use the makeMiddlewareRequest function for an alternative approach. See examples/makeMiddlewareRequest.php.
Documentation
Detailed documentation can be found in the docs folder:
- Example Outputs - Shows sample outputs from key methods like getAllTransactions(), getLastTransaction(), getTransactionSummary(), and getDebug() when handling redirect chains
- Middleware Algorithm - Explains the algorithm used to handle redirects and other middleware
- Middleware Flow - A sequence diagram showing the flow of the MiddlewareClient
- Middleware Structure - A Mermaid markdown diagram showing the structure of the MiddlewareClient
Configuration Options
The MiddlewareClient constructor accepts the following parameters:
$config(array): Guzzle configuration options$logger(LoggerInterface): A PSR-3 compatible logger$proxyConfig(array): Proxy configuration options
Proxy Configuration
To use a proxy with the MiddlewareClient:
Testing and Development
Remember to start the development server before running tests.
To run the PHPUnit test suite through composer:
To use PHPStan for static analysis:
To use PHP-CS-Fixer for code style:
License
The MIT License (MIT). Please see License File for more information.
Credits
This package is built on top of Guzzle, a PHP HTTP client library.
All versions of guzzle-middleware with dependencies
guzzlehttp/guzzle Version ^7.9
psr/log Version ^3.0
fofx/helper Version ^1.1