genxoft/curl Simple php cURL extension with RESTful support

php-curl wrapper

  1. Requirements
  2. Installation
  3. Quick usage
  4. Basic usage
  5. Donate
  6. LICENSE

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.

php composer.phar require genxoft/curl "*"

or

composer require genxoft/curl "*"

Quick usage

Quick get request
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

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();
    }
}

Donate

btn_donateCC_LG.gif

LICENSE

This curl wrapper is released under the MIT license.

0 0
1 follower
144 downloads
Yii Version: Unknown
License: MIT
Category: Web Service
Developed by: Simon Rodin
Created on: Dec 18, 2018
Last updated: (not set)
Packagist Profile
Github Repository

Related Extensions