PHPackages                             mohiwalla/php-fetch - 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. mohiwalla/php-fetch

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

mohiwalla/php-fetch
===================

A PHP utility for customizable fetch requests with support for HTTP methods, headers, body, timeout, and SSL verification, handling input validation and cURL errors.

1.0.0(1y ago)112MITPHPPHP &gt;=7.0

Since Jul 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mohiwalla/php-fetch)[ Packagist](https://packagist.org/packages/mohiwalla/php-fetch)[ Docs](https://github.com/mohiwalla/php-fetch)[ RSS](/packages/mohiwalla-php-fetch/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Fetch Utility
=================

[](#php-fetch-utility)

A PHP utility for performing fetch requests with customizable options such as HTTP method, headers, body, timeout, and SSL verification. The utility validates input and handles cURL errors, making it easy to send HTTP requests and receive responses in various formats.

### Requirements

[](#requirements)

- PHP 7.0 or higher
- cURL extension enabled

### Installation

[](#installation)

To install the utility, you can use Composer. Add the following to your `composer.json` file:

```
{
	"require": {
		"mohiwalla/php-fetch": "1.0.0"
	}
}
```

Then run:

```
composer install
```

OR just run this command directly:

```
composer require mohiwalla/php-fetch
```

### Usage

[](#usage)

Include the utility in your PHP script and use the `fetch` function to perform HTTP requests.

#### Basic Example

[](#basic-example)

```
require __DIR__ . '/vendor/mohiwalla/php-fetch/index.php';

$res = fetch('https://dummyjson.com/users/1');
$data = json_decode($res);

echo print_r($data, true);
```

#### Supported Options

[](#supported-options)

- **method**: The HTTP method to use for the request (default: `GET`).
- **headers**: An associative array of custom headers to include in the request.
- **body**: The request body data, used with methods like `POST` and `PUT`.
- **timeout**: Request timeout in seconds (default: `30`).
- **ssl\_verify**: Whether to verify SSL certificates (default: `false`).

#### Exception Handling

[](#exception-handling)

The `php-fetch` utility throws the following exceptions:

- `InvalidArgumentException`: If the options parameter is not an array or an invalid HTTP method is specified.
- `RuntimeException`: If a cURL error occurs during the request.

### Contributing

[](#contributing)

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Make your changes.
4. Commit your changes (`git commit -am 'Add new feature'`).
5. Push to the branch (`git push origin feature-branch`).
6. Create a new Pull Request.

### License

[](#license)

This project is licensed under the MIT License. See the [LICENSE](https://github.com/mohiwalla/php-fetch/blob/main/LICENSE) file for details.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

719d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/121000462?v=4)[Kamaljot Singh](/maintainers/mohiwalla)[@mohiwalla](https://github.com/mohiwalla)

---

Top Contributors

[![mohiwalla](https://avatars.githubusercontent.com/u/121000462?v=4)](https://github.com/mohiwalla "mohiwalla (12 commits)")

---

Tags

curl libraryfetch-phpfetch apicurl phpphp-fetchcrulcurl fetch

### Embed Badge

![Health badge](/badges/mohiwalla-php-fetch/health.svg)

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M91](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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