PHPackages                             ralphschindler/phetch - 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. ralphschindler/phetch

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

ralphschindler/phetch
=====================

A Nice HTTP Client For PHP

04PHPCI failing

Since Oct 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ralphschindler/phetch)[ Packagist](https://packagist.org/packages/ralphschindler/phetch)[ RSS](/packages/ralphschindler-phetch/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Phetch
======

[](#phetch)

Phetch is the missing 80% use case HTTP client for PHP. Phetch did not invent anything new, rather it is borrowing and building these ideas &amp; desires:

- API is natural, comfortable, and pleasant to use
- A Zttp like client without the Guzzle dependency
- As approachable as HTTPie
- Json by default / Sensible defaults
- Lightweight wrapper of PHP stream (http, ssl) functionality
- Has shallow stack traces
- Service container friendly

Install
=======

[](#install)

```
$ composer require ralphschindler/phetch

```

Usage
=====

[](#usage)

#### GET With Query Parameters

[](#get-with-query-parameters)

```
// simple call to the Github API
$resp = Phetch\Phetch::withBearerAuth('abcdefghijklmnopqrstuvwxyz0123456789')
    ->get('https://api.github.com/repos/ralphschindler/phetch/issues', ['state' => 'all']);

$resp->json(); // the response body as an array
```

#### POST with body

[](#post-with-body)

```
$response = Phetch\Phetch::request()->post('https://api.github.com/repos/ralphschindler/phetch/issues', [
    'title' => 'My Issue',
    'body' => 'This is the body to my issue',
]);
```

#### PATCH

[](#patch)

```
$response = Phetch\Phetch::request()->patch('https://api.github.com/repos/ralphschindler/phetch/issues/1', [
    'title' => 'My Issue Updated Title!',
]);
```

#### DELETE, with special headers at call time

[](#delete-with-special-headers-at-call-time)

```
// locking github issues requires a special accept header
$response = Phetch\Phetch::request()->delete('https://api.github.com/repos/ralphschindler/phetch/issues/1/lock',
    ['headers' => ['Accept' => 'application/vnd.github.sailor-v-preview+json']]
);
```

#### Other special helper methods

[](#other-special-helper-methods)

##### Setting a base url for repeated calls at the same web service:

[](#setting-a-base-url-for-repeated-calls-at-the-same-web-service)

```
$req = Phetch\Phetch::withBaseUrl('https://api.github.com');
$respGet = $request->get(...);
$respPatch = $request->patch(...);
```

##### Without verifying the SSL Certificate

[](#without-verifying-the-ssl-certificate)

```
$page = Phetch\Phetch::withoutVerifying()->get('https://IDidntUpdateMyCert.org');
```

##### Not following redirects

[](#not-following-redirects)

```
$page = Phetch\Phetch::withoutRedirecting()->get('https://AUrlThatRedirects.com/place');
```

##### Basic Authentication

[](#basic-authentication)

```
$page = Phetch\Phetch::withBasicAuth($username, $password)->get('https://AUrlThatRedirects.com/place');
```

##### Bearer authentication

[](#bearer-authentication)

```
$page = Phetch\Phetch::withBearerAuth($token)->get('https://AUrlThatRedirects.com/place');
```

As A Service Inside An Application
----------------------------------

[](#as-a-service-inside-an-application)

Often times you may want to pre-configure a request to be used with shared settings in different contexts. Additionally, you may want to build a web-service specific client.

### Setup the service

[](#setup-the-service)

Creating a service allows you to configure and share a `PendingRequest` object with as much boilerplate as necessary for your app to talk to a particular service. (`$container` is assumed to be some kind of service container.)

```
$githubWebService = Phetch\Phetch::createService(function ($pendingRequestPrototype) {
    $pendingRequestPrototype->withHeaders(['User-Agent' => 'My Applications Http Client v1.0.0'])
        ->withBaseUrl('https://api.github.com')
        ->withBearerAuth('abcdefghijklmnopqrstuvwxyz0123456789');
});

$container->share('github-web-service', $githubWebService);
```

### Use the service somewhere in your application code (controller, service classes, etc)

[](#use-the-service-somewhere-in-your-application-code-controller-service-classes-etc)

The `PhetchService` now contains your prototypical `PendingRequest`object that is preconfigured for use everywhere in your application. Each time you call `$service->request()`, you will get a cloned/fresh `PendingRequest`object that you can interact with. State changes to this new object will not affect the service's pre-configured object:

```
/** @var \Phetch\PhetchService $github */
$github = $container->get('github-web-service');

// request() will always produce a fresh & pre-configured \Phetch\PendingRequest
$resp = $github->request()
    ->get('/repos/ralphschindler/phetch/issues', ['state' => 'closed']);
```

Todo
----

[](#todo)

- httpie command parsing
- command line phetch client
- curl adapter (good open source contribution would be nice!)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c4a15cb4e97bc39a3aea8304fb04d56c0d753f2a6b79c83db0a894647ba8de7?d=identicon)[ralphschindler](/maintainers/ralphschindler)

---

Top Contributors

[![ralphschindler](https://avatars.githubusercontent.com/u/76674?v=4)](https://github.com/ralphschindler "ralphschindler (9 commits)")

### Embed Badge

![Health badge](/badges/ralphschindler-phetch/health.svg)

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

###  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)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[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)

PHPackages © 2026

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