Skip to content

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.

Notifications You must be signed in to change notification settings

effectra/http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

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:

composer require effectra/http-client

Usage

To send an HTTP request, create an instance of the Client class and call the sendRequest method:

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.

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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages