PHPackages                             weidizhang/php-curl-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. weidizhang/php-curl-wrapper

ActiveLibrary[HTTP &amp; Networking](/categories/http)

weidizhang/php-curl-wrapper
===========================

A wrapper for cURL that makes it easy to use/manage requests and responses.

019PHP

Since Sep 5Pushed 9y agoCompare

[ Source](https://github.com/weidizhang/PHP-Curl-Wrapper)[ Packagist](https://packagist.org/packages/weidizhang/php-curl-wrapper)[ RSS](/packages/weidizhang-php-curl-wrapper/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Curl-Wrapper
================

[](#php-curl-wrapper)

Created by Weidi Zhang

About
-----

[](#about)

Easily make HTTP requests and get response information with cURL.

Installation
------------

[](#installation)

```
composer require weidizhang/php-curl-wrapper:dev-master

```

Usage
-----

[](#usage)

First, require the autoloader and use the Curl class.

```
require "vendor/autoload.php";
use weidizhang\PHPCurlWrapper\Curl;

```

Create a new Curl object

```
$curl = new Curl();

```

### Changing default behavior

[](#changing-default-behavior)

```
use weidizhang\PHPCurlWrapper\Behavior;

$curl->setBehavior( ... );

```

Options: KEEP\_HEADERS, CLEAR\_HEADERS.

See src/Behavior.php to see what these do.

Default: CLEAR\_HEADERS

### Setting various cURL options

[](#setting-various-curl-options)

```
$curl->setReferer( ... );
$curl->setUserAgent( ... );
$curl->setHeader( name, value );
$curl->setHeaders( array(
	"Header1: value1",
	"Header2: value2"
) );
$curl->unsetHeader( name );
$curl->setCookieFile( filename or path );
$curl->enableSSLVerify();
$curl->disableSSLVerify();

```

### Setting custom cURL options

[](#setting-custom-curl-options)

You can pass in the option either as a constant or string.

All these do the same thing:

```
$curl->setOption(CURLOPT_FRESH_CONNECT, true);
$curl->setOption("CURLOPT_FRESH_CONNECT", true);
$curl->setOption("FRESH_CONNECT", true);

```

### Making a request

[](#making-a-request)

```
$response = $curl->request( type, url, query [optional], options [optional] );

```

type = GET, POST, HEAD, PUT, etc. Custom request types are supported.

url = URL.

query = Query to send, it can be an array or string.

options = An array of curl options to set. It calls `$curl->setOption( ... );` for them.

### Getting cURL handle

[](#getting-curl-handle)

If you need access to the cURL handle for whatever reason:

```
$curl->getHandle();

```

### Handling the response

[](#handling-the-response)

Getting body data: (Both work)

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

```

Getting cURL request information:

```
$info = $response->getInfo();

```

Getting all headers:

```
$headers = $response->getHeaders();

```

Getting a specific header:

```
$header = $response->getHeader( name );

```

Checking for errors (Usually not necessary):

```
if ($response->hasError()) {
	$error = $response->getError();
}

```

License
-------

[](#license)

Please read LICENSE.md to learn about what you can and cannot do with this source code.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d80331b4be2a4b621515a1deca6cc5217df2622e019d4bf4dc336ec00963739a?d=identicon)[ebildude123](/maintainers/ebildude123)

---

Top Contributors

[![weidizhang](https://avatars.githubusercontent.com/u/4133577?v=4)](https://github.com/weidizhang "weidizhang (1 commits)")

### Embed Badge

![Health badge](/badges/weidizhang-php-curl-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/weidizhang-php-curl-wrapper/health.svg)](https://phpackages.com/packages/weidizhang-php-curl-wrapper)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
