Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 25 days 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 (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-11-11T22:30:13.000Z (about 3 years ago)
- Last Synced: 2024-11-07T23:38:51.615Z (about 1 month ago)
- Topics: composer, curl, curl-library, curlphp, php-library, php-package, wrapper
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-indo-projects - cURL Lib - Simple Wrapper for cURL. (PHP)
- awesome-indonesia-repo - cURL Lib - Simple Wrapper for cURL. (PHP)
- awesome-vietnam-repo - cURL Lib - Simple Wrapper for cURL (PHP)
README
# Simple cURL Library
![](https://badgen.net/github/release/andhikayuana/curl-lib?icon=github&color=green)
![](https://badgen.net/packagist/v/andhikayuana/curl-lib?color=orange)
![](https://badgen.net/packagist/license/andhikayuana/curl-lib)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
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/T6T02OS5W)