Download the PHP package efabrica/http-client without Composer
On this page you can find all versions of the php package efabrica/http-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download efabrica/http-client
More information about efabrica/http-client
Files in efabrica/http-client
Package http-client
Short Description Wraps Symfony HTTP client, adds named arguments.
License MIT
Informations about the package http-client
eFabrica HTTP Client
efabrica/http-client is a PHP package that provides a simple and efficient HTTP client based on Symfony's HttpClient component. It adds named arguments in constructor and methods, and provides a more statically analysable API for making HTTP requests. If Symfony changes the HttpClient component, this package's effort will be to avoid breaking changes.
Installation
You can install the package using Composer. Run the following command in your project's root directory:
⚠️ PHP >=8.1 is required.
Usage
Creating an instance
To create an instance of the HttpClient
class, use the create
method. This method allows you to configure various options for the HTTP client, such as base URL, headers, authentication, and more.
Making Requests
The HttpClient
class provides methods for making different types of HTTP requests: GET, POST, PUT, PATCH, DELETE.
Handling Asynchronous Responses
The HttpClient
class returns HttpResponse
object which implements Symfony's ResponseInterface
.
This allows you to work with responses asynchronously without blocking until their methods are called.
Streaming Responses
You can use the stream
method to yield responses chunk by chunk as they complete.
Adding Decorators
You can enhance the functionality of the HttpClient
by adding decorators. Decorators can modify or extend the behavior of the underlying HTTP client.
Updating Options
This example shows how to create a new instance of HttpClient
with updated options using the withOptions
method.
The original HttpClient
instance remains unchanged.
Tracy integration
Contributions
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
All versions of http-client with dependencies
ext-curl Version *
symfony/http-client Version ^6.4|^7.0
symfony/stopwatch Version ^6.4|^7.0