PHPackages                             zangue/prest - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. zangue/prest

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

zangue/prest
============

A REST client for PHP based on Pest.

v1.0.0(10y ago)09MITPHPPHP &gt;=5.5.0

Since Apr 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/zangue/prest)[ Packagist](https://packagist.org/packages/zangue/prest)[ Docs](https://github.com/zangue/prest)[ RSS](/packages/zangue-prest/feed)WikiDiscussions master Synced yesterday

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

Prest
=====

[](#prest)

Prest is a PHP REST client library based on [Pest](https://github.com/educoder/pest). In a nutshell Prest is a wrapper around Pest that let you write RESTful client in a more elegant way (imho).

Installation
------------

[](#installation)

Via composer cli:

```
composer require zangue/prest
```

or in your composer.json file:

```
{
    "require": {
        "zangue/prest": "1.0.0"
    }
}

```

Basic Usage
-----------

[](#basic-usage)

```
$factory = new PrestFactory('http://example.com');

$rest = $factory->create()
    ->url('/resource')
    ->withHeader('Authorization', 'Basic ' . OAUTH_BASIC))
    ->contentType('application/x-www-form-urlencoded')
    ->accept('application/json')
    ->data('data1', value1)
    ->data('data2', value2)
    ->viaPost()
    ->execute();

if ($rest->succeed()) {
    var_dump($rest->getResponseBody());
} else {
    ...
}

$rest->reset()
    ->url('/delete/13')
    ->viaDelete()
    ->execute();

if ($rest->failed()) {
    $e = $rest->getException();

    var_dump($e->getMessage());
}

$rest2 = $factory->create('http://base-url.com')
    ->url('/uri')
    ->viaGet()
    ->execute();

...
```

Just as with Pest one can use the createJSON() and createXML() factory methods to create JSON and XML-centric version of Prest.

API
---

[](#api)

```
Prest url (string $value)
```

Set the resource URL.

```
string getUrl ()
```

Returns the resource URL, empty string if not set.

```
Prest withHeader (string $key, string $value)
```

Adds a header.

```
array getHeaders ()
```

Returns the request headers, empty array if no headers were set.

```
Prest contentType (string $value)
```

Shortcut: adds Content-Type header.

```
Prest data (mixed $key, mixed $value)
```

Adds request data

```
Prest arrayData (array $data)
```

Use this method to pass a prepared array of data. Argument has to be an array else nothing will happened!

```
array getData ()
```

Returns the request data, empty array if no data were set.

```
Prest withCookie (string $name, string $value)
```

Add a cookie.

```
array getCookies ()
```

Returns array of cookies or empty array if no cookies were added to the request.

```
Prest withAuth (string $user, string $pass, string $auth = 'basic')
```

Setup authentication. $auth can basic (default) or disgest.

```
Prest withProxy (string $host, int $port, [string $user, string $pass])
```

Setup proxy.

```
Prest function curlOpts (string $option, mixed $value)
```

Set cURL option.

```
boolean succeed ()
boolean failed()
```

Tells if the request was successful/failed.

```
int getStatus ()
```

Get last response status code

```
Exception getException ()
```

Return the raised exception in case of failure.

```
mixed getResponseBody ()
```

Returns the last response body on success. This method will return an associative array or a SimpleXMLElement if the Prest object was created using `createJSON` or `createXML`factory method respectively.

```
boolean responseHasHeader (string $header)
```

Checks if last response has a specific header.

```
string getResponseHeader (string $header)
```

Returns the last response header (case insensitive) or NULL if not present.

```
Prest viaGet ()
Prest viaPost ()
Prest viaPut ()
Prest viaPatch ()
Prest viaHead ()
Prest viaDelete ()
```

Use HTTP GET/POST/PUT/PATCH/HEAD/DELETE method.

```
Prest execute ()
```

Executes the request.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

3715d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6109563?v=4)[/zɒ̃ge/](/maintainers/zangue)[@zangue](https://github.com/zangue)

---

Top Contributors

[![zangue](https://avatars.githubusercontent.com/u/6109563?v=4)](https://github.com/zangue "zangue (29 commits)")

---

Tags

phpapiclientpestrestprest

### Embed Badge

![Health badge](/badges/zangue-prest/health.svg)

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

PHPackages © 2026

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