PHPackages                             juanchosl/curlclient - 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. juanchosl/curlclient

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

juanchosl/curlclient
====================

A small, lightweight utility to perform curl calls using GET, POST, PUT, PACTH, DELETE, HEAD, TRACE, OPTIONS methods...

1.0.8(4mo ago)11631MITHTMLPHP ^8.1

Since Nov 6Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/JuanchoSL/CurlClient)[ Packagist](https://packagist.org/packages/juanchosl/curlclient)[ Docs](https://github.com/JuanchoSL/CurlClient)[ RSS](/packages/juanchosl-curlclient/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (9)Dependencies (12)Versions (11)Used By (1)

CurlClient
==========

[](#curlclient)

Info
----

[](#info)

This is a class based on native php curl functions in order to perform requests and retrieve responses from remote servers

Install
-------

[](#install)

Use composer in order to install the module

### Add the dependency

[](#add-the-dependency)

```
composer require juanchosl/curlclient
```

or

### Install

[](#install-1)

```
"require": {
    "juanchosl/curlclient": "1.0.*"
},
```

and

```
$ composer install
```

How to use
----------

[](#how-to-use)

### Native cURL lib implementation

[](#native-curl-lib-implementation)

> CurlRequest has been marked as **DEPRECATED**, use **Factories** or specyfic handler type

```
use JuanchoSL\CurlClient\CurlRequest;

$extra_headers = ['Content-type' => 'application/json'];

$curl = new CurlRequest();
$curl->setSsl(true);
$response = $curl->post($url, json_encode([$key => $value]), $extra_headers);

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

#### HTTP Request

[](#http-request)

For use with servers using http comunications, with apis or webservers

```
use JuanchoSL\CurlClient\Engines\Http\CurlHttpRequest;

$extra_headers = ['Content-type' => 'application/json'];

$curl = new CurlHttpRequest();
$curl->setSsl(true);
$response = $curl->post($url, json_encode([$key => $value]), $extra_headers);

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

#### FTP Request

[](#ftp-request)

For use with servers using ftp protocols, ftp and ftps

```
use JuanchoSL\CurlClient\Engines\Ftp\CurlFtpRequest;

$curl = new CurlFtpRequest();
$curl->setSsl(true);
$curl->setPasive(true);
$response = $curl->post("ftps://username:password@host:port/directory/filename.ext", file_get_contents("/path/local/file.ext"));

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

#### SMTP Request

[](#smtp-request)

For use with smtp servers using single authentication, for send emails

```
use JuanchoSL\CurlClient\Engines\Email\CurlEmailRequest;

$curl = new CurlEmailRequest();
$curl->setSsl(true);
$response = $curl->post("smtps://username:password@host:port", file_get_contents("/path/to/full/formed/message.eml"));
```

#### Handlers

[](#handlers)

In order to construct a CurlHandle and prepare the request for future use (as a Batch), use the equivalent CurlXXXHandler and call the prepare{METHOD}, retrieving a standard php CurlHandle

```
use JuanchoSL\CurlClient\Engines\Http\CurlHttpHandler;

$extra_headers = ['Content-type' => 'application/json'];

$curl = new CurlHttpHandler();
$curl->setSsl(true);
$curl_handle = $curl->preparePost($url, json_encode([$key => $value]), $extra_headers);
```

### PSR-18 Client interface implementation

[](#psr-18-client-interface-implementation)

#### Create a PSR-7 Request using PSR-17 Factory and send using the PSR-18 Client implementation

[](#create-a-psr-7-request-using-psr-17-factory-and-send-using-the-psr-18-client-implementation)

```
$request = (new RequestFactory)
    ->createRequest('GET', 'https://www.tecnicosweb.com')
    ->withProtocolVersion('1.1')
    ->withHeader('User-agent',(new UserAgent())->getDesktopWindows(1))
    ->withAddedHeader('Accept','text/html');

$response = (new PsrCurlClient)->sendRequest($request);

print_r($response);
```

#### Returns a PSR-7 Response

[](#returns-a-psr-7-response)

```
JuanchoSL\HttpData\Containers\Response Object
(
    [protocol_version:protected] => 1.1
    [headers:protected] => Array
        (
            [Date] => Array
                (
                    [0] => Sat, 15 Mar 2025 22:45:48 GMT
                )

            [Content-Type] => Array
                (
                    [0] => text/html; charset=UTF-8
                )

            [Transfer-Encoding] => Array
                (
                    [0] => chunked
                )

            [Connection] => Array
                (
                    [0] => keep-alive
                )

            [Server] => Array
                (
                    [0] => OVHcloud
                )

            [X-Powered-By] => Array
                (
                    [0] => PHP/8.3
                )

            [Set-Cookie] => Array
                (
                    [0] => PHPSESSID=82ba4ec20aa3c3b024c49f3db3d56255; path=/
                )

            [X-Content-Type-Options] => Array
                (
                    [0] => nosniff
                )

            [ETag] => Array
                (
                    [0] => "5ded4b575dbc971a6f22e31632c3b9ff"
                )

            [Expires] => Array
                (
                    [0] => Sun, 16 Mar 2025 22:33:11 GMT
                )

            [Cache-control] => Array
                (
                    [0] => max-age=85643
                    [1] => private
                )

            [Pragma] => Array
                (
                    [0] => cache
                )

            [User-Cache-Control] => Array
                (
                    [0] => max-age=85643
                )

            [Last-Modified] => Array
                (
                    [0] => Sat, 15 Mar 2025 22:33:11 GMT
                )

            [Vary] => Array
                (
                    [0] => Accept-Encoding
                    [1] => User-Agent
                )

        )

    [body:protected] => JuanchoSL\HttpData\Containers\Stream Object
        (
            [resource:protected] => Resource id #51
            [meta:protected] => Array
                (
                )

        )

    [status_code:protected] => 200
    [reasonPhrase:protected] => OK
)
```

#### Extract the response stream body contents from the previous PSR-7 Response

[](#extract-the-response-stream-body-contents-from-the-previous-psr-7-response)

```
>

    Diseño páginas Web Terrassa

```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance77

Regular maintenance activity

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~61 days

Total

10

Last Release

119d ago

PHP version history (2 changes)1.0.0PHP ^7.1 || ^8.0

1.0.7PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![JuanchoSL](https://avatars.githubusercontent.com/u/18701207?v=4)](https://github.com/JuanchoSL "JuanchoSL (87 commits)")

---

Tags

httprequestftpapiclientcurloptionssshsftppsr7tracessh2connectgetpostdeleteputftpspsr18patchhead

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juanchosl-curlclient/health.svg)

```
[![Health](https://phpackages.com/badges/juanchosl-curlclient/health.svg)](https://phpackages.com/packages/juanchosl-curlclient)
```

###  Alternatives

[aplus/http-client

Aplus Framework HTTP Client Library

2161.6M1](/packages/aplus-http-client)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[elementaryframework/water-pipe

URL routing framework and requests/responses handler for PHP

254.6k4](/packages/elementaryframework-water-pipe)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[pdeans/http

PSR-7 cURL HTTP client with support for PSR-17 HTTP factories.

1466.2k3](/packages/pdeans-http)

PHPackages © 2026

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