Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/effectra/http-client
Effectra's HTTP Client is a lightweight PHP library for sending HTTP requests. With cURL integration, it supports various methods and headers. Simplify API interactions with a streamlined design and intuitive API. Ideal for interacting with HTTP-based services.
https://github.com/effectra/http-client
api api-client client fetch-api http http-client http-message php psr psr-18
Last synced: about 2 months ago
JSON representation
Effectra's HTTP Client is a lightweight PHP library for sending HTTP requests. With cURL integration, it supports various methods and headers. Simplify API interactions with a streamlined design and intuitive API. Ideal for interacting with HTTP-based services.
- Host: GitHub
- URL: https://github.com/effectra/http-client
- Owner: effectra
- Created: 2023-05-20T12:23:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-13T11:20:16.000Z (over 1 year ago)
- Last Synced: 2024-11-07T21:38:47.788Z (3 months ago)
- Topics: api, api-client, client, fetch-api, http, http-client, http-message, php, psr, psr-18
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Effectra HTTP Client
Effectra HTTP Client is a lightweight PHP library that simplifies sending HTTP requests and handling responses. It provides an intuitive interface and utilizes cURL for efficient communication with HTTP-based APIs and services.
## Installation
You can install the library using Composer. Run the following command in your project directory:
```shell
composer require effectra/http-client
```## Usage
To send an HTTP request, create an instance of the `Client` class and call the `sendRequest` method:
```php
use Effectra\Http\Client\Client;
use Effectra\Http\Message\Request;
use Effectra\Http\Message\Uri;$client = new Client();
// Create a request object
$request = new Request('GET', new Uri('https://api.example.com/users'));// Send the request and get the response
$response = $client->sendRequest($request);// Access the response status code
$status = $response->getStatusCode();// Access the response headers
$headers = $response->getHeaders();// Access the response body as a string
$body = $response->getBody()->getContents();// Process the response data as needed
// ...
```You can also use convenience methods like `get`, `post`, `put`, `patch`, `delete`, and `head` to send requests with specific methods.
```php
use Effectra\Http\Client\Client;$client = new Client();
// Send the request and get the response
$response = $client->get('https://api.example.com/users');// Access the response status code
$status = $response->getStatusCode();// Access the response headers
$headers = $response->getHeaders();// Access the response body as a string
$body = $response->getBody()->getContents();// Process the response data as needed
// ...
```## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests for any improvements or bug fixes you'd like to contribute.
## License
This library is licensed under the [MIT License](LICENSE).