isikiyski/fgc_client

There is no license information available for the latest version (dev-main) of this package.

file_get_contents curlable wrapper

dev-main 2023-01-23 09:23 UTC

This package is auto-updated.

Last update: 2025-06-29 02:16:53 UTC


README

Wrapper HTTP Client utilising file_get_contents in PHP

Requirements

  • PHP >= 8.0

Installation

composer require isikiyski/fgc_client

Usage

$o = new \Isikiyski\Client\FGCClient('https://some-url');

$o->setHeaders([
    'Authorization' => 'Basic w231313331',
    'x-api-key' => 'rand',
    'Content-Type' => 'application/json',
]);

$payload = ["message" => "test"];

$o->setTimeout(60);

$o->post('', $payload);

if ($ec = $o->getErrorCode()) {
    echo $ec . PHP_EOL;
}
if ($em = $o->getErrorMessage()) {
    echo $em . PHP_EOL;
}

echo $o->getResponseHeaders() . PHP_EOL;
echo $o->getHttpStatusCode() . PHP_EOL;
echo $o->getRawResponse() . PHP_EOL;
//
// ....
//

Notes

Using this client instead of regular curl will be faster IF you destroy the curl handle on each request. However, reusing the curl handle resource will yield better results.

Strongly suggest using this client in Swoole's coroutines - it yields 92% better performance than regular curl WITH reusing the curl handle resource.