mykehowells / httpeep
PHP HTTP client for API endpoint/resource requests
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mykehowells/httpeep
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2025-10-12 18:40:35 UTC
README
PHP HTTP client for API endpoint/resource requests
Setup
Composer
If you use composer, enter the following command into terminal:
composer require mykehowells/httpeep
Then add require 'vendor/autoloader.php' to your PHP project.
Non-Composer
To start using HttPeep, clone this repo into your project; Using SPL autoloader, enter the following code into your project to load the required files.
set_include_path( CLASSES_DIR ); spl_autoload_extensions('.class.php'); spl_autoload_register();
This will include the files as they are called within your project and within he HttPeep files.
Usage
A simple use case of HttPeep, is below;
$client = new \HttPeep\Client( 'https://api.example.com' ); $response = $client->post( "/user/auth", [ 'token' => $_SESSION['api']['token'], 'username' => $_POST['username'], 'password' => md5( $_POST['password'] ) ] ); var_export( $response );
You can also use the \HttPeep\Client->json() method to return JSON taken from the body.
$client = new \HttPeep\Client( 'https://api.example.com' ); $response = $client->post( "/user/auth", [ 'token' => $_SESSION['api']['token'], 'username' => $_POST['username'], 'password' => md5( $_POST['password'] ) ] )->json(); var_export( $response );
Methods
Methods available from HttPeep are:
- GET
- POST
- DELETE
- PUT
Client Config
When instantiating \HttPeep\Client(), you can pass an array of config variables for cURL; for example:
$client = new \HttPeep\Client( 'https://api.example.com', [ 'curl' => [ 'followlocation' => true, // CURLOPT_FOLLOWLOCATION - follow any Location: header sent as part of the HTTP header 'maxredirs' => 10 // CURLOPT_MAXREDIRS - Maximum number of HTTP redirections to follow ] ] );
Default CURLOPTS that are set within the Client are:
| Option | Value |
|---|---|
| CURLOPT_RETURNTRANSFER | true |
| CURLOPT_SSL_VERIFYPEER | false |
| CURLOPT_SSL_VERIFYHOST | false |
| CURLOPT_VERBOSE | false |