Skip to content

Latest commit

 

History

History
97 lines (73 loc) · 1.92 KB

README.md

File metadata and controls

97 lines (73 loc) · 1.92 KB

Simple cURL Library

Simple wrapper for cURL using PHP.

NOTE: Supported composer package from v2.0.0, If you need native version you can check v1.0.0

Installation

composer require andhikayuana/curl-lib

Usage

Create instance

require 'vendor/autoload.php';

$curl = new \Yuana\Curl();

HTTP GET method

$res = $curl->get('http://api.halo.com/users');

// using query
// http://api.halo.com/users?users_id=2
$res = $curl->get('http://api.halo.com/users', [
    'users_id' => 2
]);

HTTP POST method

$res = $curl->post('http://api.halo.com/login', [
    'username' => 'yuana',
    'password' => 'yourpassword'
]);

HTTP PUT method

$res = $curl->put('http://api.halo.com/users', [
    'users_id' => 3,
    'users_name' => 'Yuana Andhika',
    'users_dept' => 'Android Developer'
]);

HTTP DELETE method

$res = $curl->delete('http://api.halo.com/users', [
    'users_id' => 3
]);

Uploading file

$res = $curl->upload('http://api.domain.com/upload', [
    'fieldA' => '/path/to/file/fileA.jpg',
    'fieldB' => '/path/to/file/fileB.jpg',
]);

Configuration

//override timeout [default 30]
$curl->timeout = 25;

//override redirection [default true]
$curl->isRedirect = false;

//override user agent [default from http user agent]
$curl->userAgent = 'Android App 1.1';

//override headers
$curl->headers = [
    'Authorization' => 'Bearer yourtokenhere'
];

Contributing

Feel free to check CONTRIBUTING.md file

Todos

  • Proxy
  • Composer Package

Donation

ko-fi