2017 © Pedro Peláez
 

library pcurl

CURL wrapper for PHP >= 5.3

image

purplecode/pcurl

CURL wrapper for PHP >= 5.3

  • Monday, August 3, 2015
  • by purplecode
  • Repository
  • 1 Watchers
  • 2 Stars
  • 37 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php.curl

PCurl is a PHP client library for RESTful web services., (*1)

PCurl supports GET/POST/PUT/DELETE request methods. Unlike other similar libaries supports also HTTPS certificates verification., (*2)

Composer Installation

To install PCurl, use the following composer require statement:, (*3)

{
    "require": {
        "purplecode/pcurl": "dev-master"
    }
}

or just copy-paste content of src/ to your libs., (*4)

Usage

PCurl.php

Simple GET, (*5)

$pcurl = new PCurl('http://www.google.pl');
$response = $pcurl->get('/')->getBody();

Simple GET via HTTPS with certificate verification (more examples in test package), (*6)

$pcurl = new PCurl('https://www.google.pl');
$pcurl->useSSLCertificate(<path to crt/pem file>);
$response = $pcurl->get('/')->getBody();

and a similar example without it, (*7)

$pcurl = new PCurl('https://www.google.pl');
$pcurl->ignoreSSLCertificate();
$response = $pcurl->get('/')->getBody();

Sample POST, (*8)

$pcurl = new PCurl('http://some.fancy.page');
$pcurl->proxy(host, port);
$pcurl->auth(user, pass);
$pcurl->header('Cache-Control: no-cache');
$pcurl->contentType('application/xml');
$response = $pcurl->post('/igipigiel/xml', '<a>makapaka</a>')->getBody();

PJsonCurl.php

Class similar to PCurl, the only difference is that the input/output is passed through json_encode/json_decode., (*9)

$pcurl = new PJsonCurl('http://www.app.com/json');
$response = $pcurl->put('/', array('a' => 'b'));
echo $response->getBody()['c'];

PObjectCurl.php

Class similar to PJsonCurl, the difference is that the input/output is passed through serialize/deserialize methods. Requires JMS\Serializer library or JMSSerializerBundle Symfony2 bundle., (*10)

$pcurl = new PObjectCurl('http://www.prettifier.com/json', JMS\Serializer\SerializerInterface $serializer);
$pcurl->responseClass('My\App\Preety');
$uglyObject =  new My\App\Ugly();
$preetyObject = $pcurl->put('/', $uglyObject)->getBody();

Enjoy!, (*11)

The Versions

03/08 2015

dev-master

9999999-dev https://github.com/purplecode/php.curl

CURL wrapper for PHP >= 5.3

  Sources   Download

MIT

The Requires

  • lib-curl *
  • php >=5.3.0

 

by Mateusz Jaworski

curl php wrapper