https://github.com/genxoft/curl
Simpe PHP Curl wrapper
https://github.com/genxoft/curl
Last synced: 12 months ago
JSON representation
Simpe PHP Curl wrapper
- Host: GitHub
- URL: https://github.com/genxoft/curl
- Owner: genxoft
- Created: 2018-10-18T13:58:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-14T19:19:30.000Z (over 7 years ago)
- Last Synced: 2025-04-03T22:44:44.229Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
php-curl wrapper
================
Simple curl wrapper with REST methods support:
- GET
- HEAD
- POST
- PUT
- PATCH
- DELETE
Requirements
------------
- PHP 5.4+
- curl php extension
Installation
------------
The preferred way to install this wrapper is through [composer](http://getcomposer.org/download/).
```bash
php composer.phar require genxoft/curl "*"
```
or
```bash
composer require genxoft/curl "*"
```
Quick usage
-----------
### Quick get request
```php
require_once __DIR__ . '/vendor/autoload.php';
use genxoft\curl\Curl;
$result = Curl::QuickGet("http://example.com", ["text_param" => "text_value"]);
```
You can see also Curl::QuickPost and Curl::QuickJson quick methods
Basic usage
-----------
### Post request with Json data
Performing post request with Json data and query params
```php
require_once __DIR__ . '/vendor/autoload.php';
use genxoft\curl\Curl;
use genxoft\curl\Request;
$request = new Request("http://example.com");
$request->addGetParam("action", "save")
->setJsonBody([
"name" => "John Smith",
"age" => 23
]);
$curl = new Curl($request);
$response = $curl->post();
if ($response === null) {
echo $curl->getLastError();
} else {
if ($response->isSuccess()) {
echo "Data saved";
} else {
echo "HTTP Error: ".$response->getStatusMessage();
}
}
```
## LICENSE
This curl wrapper is released under the [MIT license](https://github.com/walkor/workerman/blob/master/MIT-LICENSE.txt).
