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

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

iamirnet/curl
=============

Curl class for PHP

2.0.3(9mo ago)0932MITPHP

Since Jun 7Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/iamirnet/curl)[ Packagist](https://packagist.org/packages/iamirnet/curl)[ Docs](https://php.iamir.net/packages/curl)[ RSS](/packages/iamirnet-curl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (13)Used By (2)

[![Latest Version](https://camo.githubusercontent.com/8b9d2bf4097d765876b5188c6dfe15ecb84e22fcf89056068d9ea50af339e784/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f69616d69726e65742f6375726c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/iamirnet/curl/releases)[![GitHub last commit](https://camo.githubusercontent.com/1b2342c178c1cabc0cdbb89343b3cf40dc872c331db3c1ff506bb4026220c483/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f69616d69726e65742f6375726c2e7376673f7374796c653d666c61742d737175617265)](#)[![Packagist Downloads](https://camo.githubusercontent.com/f372aa1f4b2a9a814e6a5ac1025f3d0e660a295f326ee3774ea62d63c2f5be98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69616d69726e65742f6375726c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iamirnet/curl)

iCurl
=====

[](#icurl)

iCurl is a lightweight PHP library for making HTTP requests using cURL. It supports various HTTP methods, handles JSON and URL-encoded data, and simplifies common cURL operations.

---

Features
--------

[](#features)

- Easy-to-use interface for HTTP methods: `GET`, `POST`, `PUT`, `DELETE`, and more.
- Automatic handling of query parameters and data formatting.
- Built-in support for file downloads.
- JSON encoding/decoding and validation utilities.
- Flexible configuration with additional cURL options.

---

#### Installation

[](#installation)

```
composer require iamirnet/curl

```

 Click for help with installationInstall Composer
----------------

[](#install-composer)

If the above step didn't work, install composer and try again.

#### Debian / Ubuntu

[](#debian--ubuntu)

```
sudo apt-get install curl php-curl
curl -s http://getcomposer.org/installer | php
php composer.phar install

```

Composer not found? Use this command instead:

```
php composer.phar require "iamirnet/curl"

```

#### Installing on Windows

[](#installing-on-windows)

Download and install composer:

1.
2. Create a folder on your drive like C:\\iAmirNet\\XT
3. Run command prompt and type `cd C:\iAmirNet\XT`
4. `composer require iamirnet/curl`
5. Once complete copy the vendor folder into your project.

#### Getting started

[](#getting-started)

`composer require iamirnet/curl`

```
require 'vendor/autoload.php';
$service = new iAmirNet\Curl\iCurlService('https://api.example.com', ['Authorization' => 'Bearer token']);
```

---

Usage
-----

[](#usage)

### Creating an iCurlService Instance

[](#creating-an-icurlservice-instance)

```
$service = new iAmirNet\Curl\iCurlService('https://api.example.com', ['Authorization' => 'Bearer token']);
```

### Sending a GET Request

[](#sending-a-get-request)

```
$response = $service->get('/endpoint', ['param1' => 'value1']);
echo $response;
```

### Sending a POST Request

[](#sending-a-post-request)

```
$data = ['key' => 'value'];
$response = $service->post('/endpoint', $data);
echo $response;
```

### Sending a PUT Request

[](#sending-a-put-request)

```
$data = ['key' => 'newValue'];
$response = $service->put('/endpoint', [], $data);
echo $response;
```

### Sending a DELETE Request

[](#sending-a-delete-request)

```
$response = $service->delete('/endpoint');
echo $response;
```

---

### Usage Static

[](#usage-static)

#### Sending a GET Request

[](#sending-a-get-request-1)

```
$response = iAmirNet\Curl\iCurl::get('https://api.example.com/data', ['key' => 'value'], ['Authorization' => 'Bearer token']);
if ($response['status']) {
    print_r($response['response']);
} else {
    echo "Error: " . $response['message'];
}
```

#### Sending a POST Request

[](#sending-a-post-request-1)

```
$data = ['name' => 'John Doe', 'email' => 'john@example.com'];
$response = iAmirNet\Curl\iCurl::post('https://api.example.com/users', [], $data, ['Content-Type' => 'application/json']);
if ($response['status']) {
    echo "User created successfully!";
} else {
    echo "Error: " . $response['message'];
}
```

#### Sending a PUT Request

[](#sending-a-put-request-1)

```
$data = ['name' => 'Jane Doe'];
$response = iAmirNet\Curl\iCurl::put('https://api.example.com/users/1', [], $data, ['Content-Type' => 'application/json']);
if ($response['status']) {
    echo "User updated successfully!";
} else {
    echo "Error: " . $response['message'];
}
```

#### Sending a DELETE Request

[](#sending-a-delete-request-1)

```
$response = iAmirNet\Curl\iCurl::delete('https://api.example.com/users/1', [], [], ['Authorization' => 'Bearer token']);
if ($response['status']) {
    echo "User deleted successfully!";
} else {
    echo "Error: " . $response['message'];
}
```

---

### Advanced Features

[](#advanced-features)

#### Downloading Files

[](#downloading-files)

```
$response = iAmirNet\Curl\iCurl::download(
    'https://files.example.com',
    '/path/to/file.zip',
    '/local/storage/file.zip',
    [],
    null,
    ['Authorization' => 'Bearer token'],
    'GET'
);

if ($response['status']) {
    echo "File downloaded to: " . $response['storage'];
} else {
    echo "Download failed: " . $response['message'];
}
```

#### Checking Resource Existence

[](#checking-resource-existence)

```
$url = 'https://example.com/resource';
if (iAmirNet\Curl\iCurl::exists($url)) {
    echo "Resource exists!";
} else {
    echo "Resource does not exist.";
}
```

#### Handling JSON

[](#handling-json)

##### Decoding JSON Responses

[](#decoding-json-responses)

```
$jsonString = '{"name":"John", "age":30}';
$decoded = iAmirNet\Curl\iCurl::json_decode($jsonString);
print_r($decoded);
```

##### Validating JSON Strings

[](#validating-json-strings)

```
$jsonString = '{"name":"John", "age":30}';
if (iAmirNet\Curl\iCurl::is_json($jsonString)) {
    echo "Valid JSON!";
} else {
    echo "Invalid JSON!";
}
```

---

iCurl Functions
===============

[](#icurl-functions)

This package provides helper functions for interacting with the iCurl class. These functions make it easy to send HTTP requests (GET, POST, PUT, DELETE) and check if a URL exists.

---

Functions Overview
------------------

[](#functions-overview)

### `i_curl`

[](#i_curl)

This function sends an HTTP request to the specified endpoint using the specified method.

```
i_curl(string $base, string $url, array $params = [], $data = null, array $headers = [], string $method = 'GET', array $options = [])
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL endpoint for the request.
- `array $params`: Optional query parameters to send with the request.
- `$data`: Optional data to send in the request body.
- `array $headers`: Optional headers to include in the request.
- `string $method`: The HTTP method (default is 'GET').
- `array $options`: Additional curl options.

**Returns:**

- The response from the `iCurl::request` function.

---

### `i_curl_get`

[](#i_curl_get)

This function sends a GET request to the specified endpoint.

```
i_curl_get(string $base, string $url, array $params = [], array $headers = [], array $options = [])
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL endpoint for the GET request.
- `array $params`: Optional query parameters to send with the GET request.
- `array $headers`: Optional headers to include in the request.
- `array $options`: Additional curl options.

**Returns:**

- The response from the `iCurl::request` function.

---

### `i_curl_post`

[](#i_curl_post)

This function sends a POST request to the specified endpoint.

```
i_curl_post(string $base, string $url, $data = null, array $params = [], array $headers = [], array $options = [])
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL endpoint for the POST request.
- `$data`: Data to send in the POST request body.
- `array $params`: Optional query parameters to send with the POST request.
- `array $headers`: Optional headers to include in the request.
- `array $options`: Additional curl options.

**Returns:**

- The response from the `iCurl::request` function.

---

### `i_curl_delete`

[](#i_curl_delete)

This function sends a DELETE request to the specified endpoint.

```
i_curl_delete(string $base, string $url, $data = null, array $params = [], array $headers = [], array $options = [])
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL endpoint for the DELETE request.
- `$data`: Optional data to send in the DELETE request body.
- `array $params`: Optional query parameters to send with the DELETE request.
- `array $headers`: Optional headers to include in the request.
- `array $options`: Additional curl options.

**Returns:**

- The response from the `iCurl::request` function.

---

### `i_curl_put`

[](#i_curl_put)

This function sends a PUT request to the specified endpoint.

```
i_curl_put(string $base, string $url, $data = null, array $params = [], array $headers = [], array $options = [])
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL endpoint for the PUT request.
- `$data`: Data to send in the PUT request body.
- `array $params`: Optional query parameters to send with the PUT request.
- `array $headers`: Optional headers to include in the request.
- `array $options`: Additional curl options.

**Returns:**

- The response from the `iCurl::request` function.

---

### `i_curl_dl`

[](#i_curl_dl)

This function downloads a file from the specified URL.

```
i_curl_dl(string $base, string $url, string $out, array $params = [], $data = null, array $headers = [], string $method = 'GET', array $options = [])
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL endpoint to download the file from.
- `string $out`: The local path to save the downloaded file.
- `array $params`: Optional query parameters to send with the request.
- `$data`: Optional data to send with the request.
- `array $headers`: Optional headers to include in the request.
- `string $method`: The HTTP method for the request (default is 'GET').
- `array $options`: Additional curl options.

**Returns:**

- The response from the `iCurl::download` function.

---

### `i_curl_exists`

[](#i_curl_exists)

This function checks if a URL exists by sending a HEAD request.

```
i_curl_exists(string $base, string $url = '')
```

**Parameters:**

- `string $base`: The base URL for the request.
- `string $url`: The specific URL to check for existence.

**Returns:**

- `true` if the URL exists, `false` if it does not.

---

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Contribution
------------

[](#contribution)

- Give us a star ⭐
- Fork and Clone! Awesome
- Select existing [issues](https://github.com/iamirnet/curl/issues) or create a [new issue](https://github.com/iamirnet/curl/issues/new) and give us a PR with your bugfix or improvement after. We love it ❤️

Donate
------

[](#donate)

- USDT Or TRX: TW5yoa21PJQe1dy1ErnCxh3kfpwDaivHQZ 😘❤

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance68

Regular maintenance activity

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

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

Every ~39 days

Recently: every ~62 days

Total

12

Last Release

277d ago

Major Versions

1.0.4.4 → 2.0.02024-12-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1670938?v=4)[Peyman Jahani](/maintainers/jahani)[@jahani](https://github.com/jahani)

---

Top Contributors

[![iamirnet](https://avatars.githubusercontent.com/u/68027783?v=4)](https://github.com/iamirnet "iamirnet (26 commits)")

---

Tags

curlhttp requesthttp-query

### Embed Badge

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

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

###  Alternatives

[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k34.5M258](/packages/rmccue-requests)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)[popphp/pop-http

Pop Http Component for Pop PHP Framework

1018.5k13](/packages/popphp-pop-http)[msankhala/parsehub-php

Php wrapper classes for Parsehub REST api.

1312.4k](/packages/msankhala-parsehub-php)

PHPackages © 2026

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