2017 © Pedro Peláez
 

library curl

Curl component for Palmtree PHP

image

palmtree/curl

Curl component for Palmtree PHP

  • Monday, May 14, 2018
  • by palmtree
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

:palm_tree: Palmtree Curl

License Travis Scrutinizer Code Coverage, (*1)

A PHP cURL wrapper to make HTTP requests easier., (*2)

Requirements

  • PHP >= 7.1

Installation

Use composer to add the package to your dependencies:, (*3)

composer require palmtree/curl

Usage

Basic Usage

You can use the static getContents method if you just want to retrieve a response body from a URL:, (*4)

<?php
use Palmtree\Curl\Curl;

$contents = Curl::getContents('https://example.org'); 

If you want access to the response headers and body, create a new instance instead:, (*5)

<?php
use Palmtree\Curl\Curl;

$curl = new Curl('https://example.org');

// Returns the response body when used as a string
echo $curl;

$response = $curl->getResponse();

$headers = $response->getHeaders();

$contentType = $response->getHeader('Content-Type');

$body = $response->getBody();

Advanced Usage

<?php
use Palmtree\Curl\Curl;

$curl = new Curl('https://example.org', [
    CURLOPT_FOLLOWLOCATION => true,
]);

$curl->getRequest()->addHeader('Host', 'example.org');

try {
    $response = $curl->execute();
} catch(CurlErrorException $e) {
}

$headers = $response->getHeaders();
$body = $response->getBody();

if($response->is404()) {
    // handle 404 error
}

if($response->isOk()) {
    // response status code is in the 2xx range
}

License

Released under the MIT license, (*6)

The Versions

14/05 2018

dev-master

9999999-dev

Curl component for Palmtree PHP

  Sources   Download

MIT

The Requires

 

14/05 2018

v0.9.4

0.9.4.0

Curl component for Palmtree PHP

  Sources   Download

MIT

The Requires

 

18/06 2017

v0.9.3

0.9.3.0

Curl component for Palmtree PHP

  Sources   Download

MIT

The Requires

 

18/06 2017

v0.9.2

0.9.2.0

Curl component for Palmtree PHP

  Sources   Download

MIT

The Requires

 

18/06 2017

v0.9.1

0.9.1.0

Curl component for Palmtree PHP

  Sources   Download

MIT

The Requires

 

18/06 2017

v0.9.0

0.9.0.0

Curl component for Palmtree PHP

  Sources   Download

MIT

The Requires