seagulltools/seagull-http

PHP HTTP client library based on guzzlehttp/guzzle

dev-master 2020-05-04 15:31 UTC

This package is auto-updated.

Last update: 2024-11-05 01:22:28 UTC


README

Installation

composer require seagulltools/seagull-http

Usage

use Seagulltools\Http\Client;

class ClassName 
{
    $client = new Client();
    
    $client->url = 'url';
    $client->method = 'post';
}

Custom Headers

//set single custom header
$client->addCustomHeader('custom-header-name', 'custom-header');

//set multiple headers 
$headers = [
   'custom-header-name-2' => 'custom-header-value-1',
   'custom-header-name-2' => 'custom-header-value-2'
];

$client->addCustomHeaders($headers);

Set Headers

//set single header
$client->header($key, $value);

//set multiple headers 
$headers = [
   'Accept' => 'application/json',
   'Content' => 'application/json'
];

$client->headers($headers);

Set Body

$client->name = 'John';
$client->surname = 'Doe';
$client->phone = '1-541-754-3010';

Send and Get Response

$client->send();

//get response
$client->getResponse();

//get status code
$client->getStatusCode();

Multipart Form

$client->multipart = true;