https://github.com/andhikayuana/curl-lib
Simple wrapper for cURL
https://github.com/andhikayuana/curl-lib
composer curl curl-library curlphp php-library php-package wrapper
Last synced: about 1 year ago
JSON representation
Simple wrapper for cURL
- Host: GitHub
- URL: https://github.com/andhikayuana/curl-lib
- Owner: andhikayuana
- License: mit
- Created: 2017-03-08T11:13:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-11-11T22:30:13.000Z (over 4 years ago)
- Last Synced: 2025-04-28T14:07:15.499Z (about 1 year ago)
- Topics: composer, curl, curl-library, curlphp, php-library, php-package, wrapper
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vietnam-repo - cURL Lib - Simple Wrapper for cURL (PHP)
- awesome-indonesia-repo - cURL Lib - Simple Wrapper for cURL. (PHP)
README
# 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](https://github.com/andhikayuana/curl-lib/tree/v1.0.0)
## Installation
```bash
composer require andhikayuana/curl-lib
```
## Usage
Create instance
```php
require 'vendor/autoload.php';
$curl = new \Yuana\Curl();
```
HTTP GET method
```php
$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
```php
$res = $curl->post('http://api.halo.com/login', [
'username' => 'yuana',
'password' => 'yourpassword'
]);
```
HTTP PUT method
```php
$res = $curl->put('http://api.halo.com/users', [
'users_id' => 3,
'users_name' => 'Yuana Andhika',
'users_dept' => 'Android Developer'
]);
```
HTTP DELETE method
```php
$res = $curl->delete('http://api.halo.com/users', [
'users_id' => 3
]);
```
Uploading file
```php
$res = $curl->upload('http://api.domain.com/upload', [
'fieldA' => '/path/to/file/fileA.jpg',
'fieldB' => '/path/to/file/fileB.jpg',
]);
```
Configuration
```php
//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](./CONTRIBUTING.md) file
## Todos
- [ ] Proxy
- [x] Composer Package
## Donation
[](https://ko-fi.com/T6T02OS5W)