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 1mo ago

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

22

—

LowBetter than 22% of packages

Maintenance33

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

670d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7b06a95da770c35d84624836fc73a20e42882addc3552244b472eb4d5580b80?d=identicon)[mohiwalla](/maintainers/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

[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)[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)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48247.0M384](/packages/php-http-curl-client)

PHPackages © 2026

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