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

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

amsify42/php-curl-http
======================

This is a PHP package for making curl http request and getting the response

1.0(4y ago)01.9k1MITPHPPHP &gt;=7.0.0CI failing

Since Sep 3Pushed 4y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (2)Used By (1)

PHP CURL HTTP
=============

[](#php-curl-http)

This is the PHP package for making http request through cURL and getting response.

### Installation

[](#installation)

```
$ composer require amsify42/php-curl-http

```

Table of Contents
-----------------

[](#table-of-contents)

1. [Initialization](#1-initialization)
2. [Request](#2-request)
3. [Response](#3-response)

### 1. Initialization

[](#1-initialization)

For creating cURL http request, we can do like this by passing url to it.

```
$curlHttp = new Amsify42\CurlHttp\CurlHttp('http://www.sample.com/users');
```

or with helper method

```
$curlHttp = get_curl_http('http://www.sample.com/users');
```

### 2. Request

[](#2-request)

If the request method is not of type `GET`, we can pass this with `CurlHtpp` instance

```
$curlHttp = new Amsify42\CurlHttp\CurlHttp('http://www.sample.com/user/create');
$curlHttp->setRequestMethod('POST');
$curlHttp->setRequestData(['name' => 'test', 'salary' => 123]);
```

or with `Amsify42\CurlHtpp\Request` instance

```
$curlRequest = new Amsify42\CurlHtpp\Request();
$curlRequest->setMethod('POST');
/**
 * Set one of the header as Content-Type: application/json if you want to pass bodyData as json
 */
$curlRequest->setHeaders(['Content-Type: application/json']);
$curlRequest->setData(['name' => 'test', 'salary' => 123]);

$curlHttp = new Amsify42\CurlHttp\CurlHttp('http://www.sample.com/user/create', $curlRequest);
```

With `Amsify42\CurlHtpp\Request` we can also call these methods.

```
$curlRequest->setMethod('PUT');
$curlRequest->setHeaders(['Authorization: Bearer sf23rsdf23fds']);
/**
 * Set request ContentType as json if you want to pass bodyData as json
 */
$curlRequest->setContenType('json');
$curlRequest->setData(['name' => 'test', 'salary' => 123]);
```

You can simply pass json encoded request data also if you don't want to pass header or contentType for json

```
$curlRequest->setData(json_encode(['name' => 'test', 'salary' => 123]));
```

For headers, you can also pass array items as key values

```
$curlRequest->setHeaders(['Authorization' => 'Bearer sf23rsdf23fds']);
```

### 3. Response

[](#3-response)

After executing the cURL through `CurlHttp`, we will get response of type `Amsify42\CurlHttp\Response`

```
$curlHttp = get_curl_http('http://www.sample.com/users');
$response = $curlHttp->execute();
```

We can call these methods with the response

```
/* To get the response code */
$response->getCode();
/* To get the response body data */
$response->getBodyData();
/* To get the response headers as array */
$response->getHeaders();
/* To get the json decoded data of response */
$response->json();
```

For executing different methods like GET, POST, PUT and DELETE, you can also call these methods to get response with a single call.

```
$response = CurlHttp::get('https://www.somsite.com/users');
$response = CurlHttp::post('https://www.somsite.com/user/create', ['name' => 'dummy'], ['Authorization: Bearer sdf23rsdf23'], 'json');
$response = CurlHttp::put('https://www.somsite.com/user/2', ['name' => 'dummy...edited'], ['Authorization: Bearer sdf23rsdf23'], 'json');
$response = CurlHttp::delete('https://www.somsite.com/user/2', ['Authorization: Basic sdf23rsdf23']);
```

Methods `post()`, `put()` and `delete()` expects three more optional parameters

```
data - expects data array or defaults to NULL
headers - expects headers array or defaults to NULL
contentType - expects either string 'json' or defaults to NULL
```

For json request data, instead of passing **contentType** parameter as `json` to these methods you can also pass one of the header as `Content-Type: application/json`

```
$response = CurlHttp::post('https://www.somsite.com/user/create', ['name' => 'dummy'], ['Authorization: Bearer sdf23rsdf23', 'Content-Type: application/json']);
```

or you can simply pass json encoded request data

```
$response = CurlHttp::post('https://www.somsite.com/user/create', json_encode(['name' => 'dummy']), ['Authorization: Bearer sdf23rsdf23']);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1712d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/125cb18a3ba00f01b2a6371254a01acc4cc4b5cf96ee4d7d2c1cd73b4d0ae1fb?d=identicon)[amsify42](/maintainers/amsify42)

---

Top Contributors

[![amsify42](https://avatars.githubusercontent.com/u/7560182?v=4)](https://github.com/amsify42 "amsify42 (8 commits)")

---

Tags

phpcurlcUrl Httpphp curl http

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[stefangabos/zebra_curl

A high performance solution for making multiple HTTP requests concurrently, asynchronously from your PHP projects using cURL

21971.3k2](/packages/stefangabos-zebra-curl)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)

PHPackages © 2026

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