krisanalfa / rikues
A simple cURL library for PHP.
0.0.3
2016-04-22 12:04 UTC
Requires (Dev)
- illuminate/support: ^5.2
- symfony/var-dumper: ^3.0
This package is auto-updated.
Last update: 2024-11-29 04:41:25 UTC
README
Rikues is a simple cURL library with serialization support.
Basic Usage
use Rikues\Rikues; $rikues = new Rikues("https://httpbin.org/get"); $response = $rikues->send();
POST Request
use Rikues\Rikues; $rikues = new Rikues("https://httpbin.org/post"); $rikues->withParam('foo', 'bar'); $rikues->withParam('baz', 'quux'); $rikues->withMethod('POST'); $response = $rikues->send();
Working With Headers
use Rikues\Rikues; $rikues = new Rikues("https://httpbin.org/get"); $rikues->withHeader('Accept', 'application/json'); $rikues->withHeader('Authorization', 'Bearer xxx'); $response = $rikues->send();
Working With Query Params
use Rikues\Rikues; $rikues = new Rikues("https://httpbin.org/get"); $rikues->withParam('foo', 'bar'); $rikues->withParam('baz', 'quux'); // Request to https://httpbin.org/get?foo=bar&baz=quux $response = $rikues->send();
Working With Exception
use Rikues\Rikues; use Rikues\Exceptions\ClientException; use Rikues\Exceptions\ServerException; $rikues = new Rikues("https://httpbin.org/get"); try { $response = $rikues->send(); } catch (ClientException $e) { echo $e->getMessage().PHP_EOL; } catch (ServerException $e) { $serverResponse = $e->response; }
Working With Serialization
$rikues = new Rikues("https://httpbin.org/post"); $rikues->withParam('foo', 'bar'); $rikues->withParam('baz', 'quux'); $rikues->withMethod('POST'); $serialized = serialize($rikues); $unserialized = unserialize($serialized); $response = $unserialized->send();