Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/palmtreephp/curl

:palm_tree: cURL wrapper to make HTTP requests easier
https://github.com/palmtreephp/curl

composer-package curl php

Last synced: about 1 month ago
JSON representation

:palm_tree: cURL wrapper to make HTTP requests easier

Awesome Lists containing this project

README

        

# :palm_tree: Palmtree Curl

[![License](http://img.shields.io/packagist/l/palmtree/curl.svg)](LICENSE)
[![Travis](https://img.shields.io/travis/palmtreephp/curl.svg)](https://travis-ci.org/palmtreephp/curl)
[![Scrutinizer](https://img.shields.io/scrutinizer/g/palmtreephp/curl.svg)](https://scrutinizer-ci.com/g/palmtreephp/curl/)
[![Code Coverage](https://scrutinizer-ci.com/g/palmtreephp/curl/badges/coverage.png)](https://scrutinizer-ci.com/g/palmtreephp/curl/)

A PHP cURL wrapper to make HTTP requests easier.

## Requirements
* PHP >= 7.1

## Installation

Use composer to add the package to your dependencies:
```bash
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:

```php
getResponse();

$headers = $response->getHeaders();

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

$body = $response->getBody();
```

### Advanced Usage

```php
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](LICENSE)