PHPackages                             php-guard/curl - 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. php-guard/curl

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

php-guard/curl
==============

PHP Curl Wrapper with multi-curl support. Easy use with CurlRequest and CurlResponse objects.

v1.1(7y ago)0221GPL-3.0-or-laterPHPPHP ^7.1

Since Oct 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/php-guard/curl)[ Packagist](https://packagist.org/packages/php-guard/curl)[ RSS](/packages/php-guard-curl/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

curl
====

[](#curl)

[![Build Status](https://camo.githubusercontent.com/139466cf47cc71b37a98d80884fe04f47a5bb7c019731f686d7ba243a7ae493f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068702d67756172642f6375726c2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/php-guard/curl/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a2a3efb40257cec6461d02e3242208eebf794c17f27ff285e8dda206fa0843d3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068702d67756172642f6375726c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/php-guard/curl/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e7d37b417d0f94108952122dce1207aa3b298d8f7647020f079e08d5aad8f080/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068702d67756172642f6375726c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/php-guard/curl/?branch=master)[![GPL Licence](https://camo.githubusercontent.com/9fbf0d3ad5e4913f3894cc264ab5c9bad31980e41b4d025fe80872a67e7ecb90/68747470733a2f2f6261646765732e66726170736f66742e636f6d2f6f732f67706c2f67706c2e706e673f763d313033)](https://opensource.org/licenses/GPL-3.0/)

This library is an alternative to "". Easy use with CurlRequest and CurlResponse objects.

### Installation

[](#installation)

Install via [Composer](https://getcomposer.org/)

```
$ composer require php-guard/curl

```

### Requirements

[](#requirements)

- php: ^7.1

### Usage

[](#usage)

##### Quick Start

[](#quick-start)

```
require __DIR__ . '/vendor/autoload.php';

use \PhpGuard\Curl\Curl;
use \PhpGuard\Curl\CurlError;

$this->curl  =  new  Curl();

try {
	// Execute a single request
	$response = $this->curl->get('http://example.com'); // Return a CurlResponse
	echo $response->raw();

	// Execute multiple requests
	$responses = $this->curl->multi() // Create a MultiCurl object
		->get('http://example.com')   // Add a get request
		->post('http://example.com')  // Add a post request
		->execute();                  // Return an array of CurlResponse

	foreach ($responses as $response) {
		echo $response->raw();
	}
} catch (CurlError $e) {
	echo 'Error: ' . $curl->getCode(). ': ' . $curl->getMessage(). "\n";
}

```

##### Available Methods

[](#available-methods)

**\\PhpGuard\\Curl\\Curl**

HTTP methods

```
get(string $url, $query = null, array $headers = []): CurlResponse
post(string $url, $data = null, $query = null, array $headers = []): CurlResponse
put(string $url, $data = null, $query = null, array $headers = []): CurlResponse
patch(string $url, $data = null, $query = null, array $headers = []): CurlResponse
delete(string $url, $data = null, $query = null, array $headers = []): CurlResponse

```

Run a single request

```
execute(CurlRequest  $request): CurlResponse

```

Prepare multiple requests

```
multi(array  $options  = []): MultiCurl

```

Edit request and response processing (advanced usage)

```
getCurlRequestFactory(): CurlRequestFactory
getRequestModifierPipeline(): RequestModifierPipeline

```

**\\PhpGuard\\Curl\\CurlRequest**

You can use Curl to execute requests or you can use the CurlRequestFactory to return CurlRequest instances.

Properties url, method and data have getters and setters.

The method `setHeaderContentType(string $contentType)` is a shortcut for

```
$curlRequest->getHeaders['Content-Type'] = $contentType

```

Other methods

```
execute(bool $throwExceptionOnHttpError = false): CurlResponse
getCurlOptions(): CurlOptions
getHeaders(): Headers

```

**\\PhpGuard\\Curl\\MultiCurl**

```
get(string $url, $query = null, array $headers = []): self
post(string $url, $data = null, $query = null, array $headers = []): self
put(string $url, $data = null, $query = null, array $headers = []): self
patch(string $url, $data = null, $query = null, array $headers = []): self
delete(string $url, $data = null, $query = null, array $headers = []): self
execute(): CurlResponse[]

```

**\\PhpGuard\\Curl\\CurlResponse**

```
statusCode(): int
isError(): bool // True if status code >= 300
headers(): Headers
raw() // Raw content of the response
json() // Array or false if not a json response

```

**\\PhpGuard\\Curl\\CurlRequestFactory**

Set the base url for all requests

```
 setBaseUrl(?string $baseUrl): self

```

Set the option curl CURLOPT\_SSL\_VERIFYPEER

```
 setSslVerifyPeer(bool $value): self

```

Create a CurlRequest

```
 create(string $method, string $url, $data = null, $query = null, array $headers = []): CurlRequest

```

Edit other default curl options

```
 getDefaultCurlOptions(): CurlOptions
 getDefaultHeaders(): Headers

```

**\\PhpGuard\\Curl\\Collection\\CurlOptions**

This class implements `\ArrayAccess`. It can therefore be used as an array.

**\\PhpGuard\\Curl\\Collection\\Headers**

This class implements `\ArrayAccess`. It can therefore be used as an array.

In addition, the keys are case insensitive.

**\\PhpGuard\\Curl\\RequestModifierPipeline**

Add an object to modify CURL requests

```
pipe(RequestModifierInterface $requestModifier): self

```

By default, FileRequestModifier and PlainTextRequestModifier are active. If necessary, you can add an instance of ProxyRequestModifier

- ProxyRequestModifier allows you to define curl options to use a proxy
- FileRequestModifier is used to manage file paths starting with @ and passed as a parameter by transforming them into CurlFile and then modifying the HTTP Content-Type header.
- PlainTextRequestModifier changes the HTTP Content-Type header to text/plain when a string is passed as a parameter.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.8% 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.

###  Release Activity

Cadence

Every ~47 days

Total

2

Last Release

2716d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10196942?v=4)[Alexandre Le Borgne](/maintainers/alexandre-le-borgne)[@alexandre-le-borgne](https://github.com/alexandre-le-borgne)

---

Top Contributors

[![alexandre-le-borgne](https://avatars.githubusercontent.com/u/10196942?v=4)](https://github.com/alexandre-le-borgne "alexandre-le-borgne (30 commits)")[![esynaps](https://avatars.githubusercontent.com/u/30432290?v=4)](https://github.com/esynaps "esynaps (1 commits)")

---

Tags

composercurlcurl-multihttpjsonpackagistphpphp-curlphp-curl-libraryphp7proxy

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  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)
