PHPackages                             xp-framework/rest - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. xp-framework/rest

AbandonedArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

xp-framework/rest
=================

REST Client and Server APIs for the XP Framework

v10.0.0(7y ago)166.4k↓28.6%2[2 PRs](https://github.com/xp-framework/rest/pulls)BSD-3-ClausePHPPHP &gt;=5.6.0

Since Jan 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/xp-framework/rest)[ Packagist](https://packagist.org/packages/xp-framework/rest)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-rest/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (35)Used By (0)

REST Client and Server APIs for the XP Framework
================================================

[](#rest-client-and-server-apis-for-the-xp-framework)

[![Build Status on TravisCI](https://camo.githubusercontent.com/488a3ceeaab56768bea8ec5da705865da5a5e96a541175cd2491a65a71d393c1/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f78702d6672616d65776f726b2f726573742e737667)](http://travis-ci.org/xp-framework/rest)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Required PHP 5.6+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-5_6plus.png)](http://php.net/)[![Supports PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.png)](http://php.net/)[![Required HHVM 3.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/hhvm-3_4plus.png)](http://hhvm.com/)[![Latest Stable Version](https://camo.githubusercontent.com/baa1a7279c485efa73c3fc5134ad41ac17a5578352e82ef3f27b4c728f0315ec/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f726573742f76657273696f6e2e706e67)](https://packagist.org/packages/xp-framework/rest)

Client
------

[](#client)

### Entry point

[](#entry-point)

The `Endpoint` class serves as the entry point to this API. Create a new instance of it with the REST service's endpoint URL and then invoke its `resource()` method to work with the resources.

### Creating: post

[](#creating-post)

```
$api= new Endpoint('http://api.example.com/');
$response= $api->resource('users')->post(['name' => 'Test'], 'application/json');

// Check status codes
if (201 !== $response->status()) {
  throw new IllegalStateException('Could not create user!');
}

// Retrieve response headers
$url= $response->header('Location');
```

### Reading: get / head

[](#reading-get--head)

```
$api= new Endpoint('http://api.example.com/');

// Unmarshal to object by optionally passing a type; otherwise returned as map
$user= $api->resource('users/self')->get()->data(User::class);

// Test for existance with HEAD
$exists= (200 === $api->resource('users/1549')->head()->status());

// Pass parameters
$list= $api->resource('user')->get(['page' => 1, 'per_page' => 50])->data();
```

### Updating: put / patch

[](#updating-put--patch)

```
$api= new Endpoint('http://api.example.com/');
$resource= $api->resource('users/self')
  ->using('application/json')
  ->accepting('application/json')
;

// Default content type and accept types set on resource used
$updated= $resource->put(['name' => 'Tested', 'login' => $mail])->data();

// Resources can be reused!
$updated= $resource->patch(['name' => 'Changed'])->data();
```

### Deleting: delete

[](#deleting-delete)

```
$api= new Endpoint('http://api.example.com/');

// Pass segments
$api->resource('user/{id}', ['id' => 6100])->delete();
```

### Execute

[](#execute)

If you need full control over the request, use the generic `execute()` method.

```
use webservices\rest\Endpoint;
use webservices\rest\RestRequest;
use peer\http\HttpConstants;

$api= new Endpoint('http://api.example.com/');

$request= (new RestRequest('/resource/{id}'))
 ->withMethod(HttpConstants::GET)
 ->withSegment('id', 5000)
 ->withParameter('details', 'true')
 ->withHeader('X-Binford', '6100 (more power)'
;

$response= $api->execute($request);
$content= $response->content();            // Raw data as string
$value= $response->data();                 // Deserialize to map
```

### Deserialization

[](#deserialization)

The REST API supports automatic result deserialization by passing a type to the `data()` method.

```
use com\example\api\types\Person;

$person= $response->data(Person::class);
$strings= $response->data('string[]');
$codes= $response->data('[:int]');
```

### Authentication

[](#authentication)

Basic authentication is supported by embedding the credentials in the endpoint URL:

```
use webservices\rest\Endpoint;

$api= new Endpoint('http://user:pass@api.example.com/');
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 84% 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 ~40 days

Recently: every ~115 days

Total

34

Last Release

2824d ago

Major Versions

v6.4.2 → v7.0.02016-02-21

v7.3.2 → v8.0.02016-09-04

v8.3.3 → v9.0.02017-06-19

v9.1.0 → v10.0.02018-08-24

PHP version history (3 changes)v6.0.0PHP &gt;=5.4.0

v6.4.0PHP &gt;=5.5.0

v9.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (14447 commits)")[![kiesel](https://avatars.githubusercontent.com/u/127769?v=4)](https://github.com/kiesel "kiesel (2392 commits)")[![ohinckel](https://avatars.githubusercontent.com/u/717217?v=4)](https://github.com/ohinckel "ohinckel (335 commits)")[![Stormwind](https://avatars.githubusercontent.com/u/836872?v=4)](https://github.com/Stormwind "Stormwind (13 commits)")[![andstefiul](https://avatars.githubusercontent.com/u/798415?v=4)](https://github.com/andstefiul "andstefiul (5 commits)")[![kusnier](https://avatars.githubusercontent.com/u/726429?v=4)](https://github.com/kusnier "kusnier (5 commits)")[![johannes85](https://avatars.githubusercontent.com/u/470531?v=4)](https://github.com/johannes85 "johannes85 (3 commits)")[![beorgler](https://avatars.githubusercontent.com/u/2027220?v=4)](https://github.com/beorgler "beorgler (3 commits)")[![treuter](https://avatars.githubusercontent.com/u/1067905?v=4)](https://github.com/treuter "treuter (3 commits)")[![ppetermann](https://avatars.githubusercontent.com/u/69334?v=4)](https://github.com/ppetermann "ppetermann (1 commits)")[![guel1973](https://avatars.githubusercontent.com/u/4669852?v=4)](https://github.com/guel1973 "guel1973 (1 commits)")

---

Tags

jsonphprestrest-clientrest-serverxmlxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-rest/health.svg)

```
[![Health](https://phpackages.com/badges/xp-framework-rest/health.svg)](https://phpackages.com/packages/xp-framework-rest)
```

PHPackages © 2026

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