PHPackages                             bennetgallein/php-restservice - 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. bennetgallein/php-restservice

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

bennetgallein/php-restservice
=============================

Simple PHP Wrapper class for making REST API calls

1.1.0(3y ago)02.4k1MITPHPPHP &gt;= 7.4

Since Apr 22Pushed 3y agoCompare

[ Source](https://github.com/bennetgallein/php-restservice)[ Packagist](https://packagist.org/packages/bennetgallein/php-restservice)[ RSS](/packages/bennetgallein-php-restservice/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (10)Used By (1)

PHP HTTP REST Client
====================

[](#php-http-rest-client)

[![Build Status](https://camo.githubusercontent.com/b27ee18228b6d1b36d7a08b512f016befc5817a2f7d775e730712ea6f894d850/68747470733a2f2f7472617669732d63692e6f72672f616268696c61736870756a6172692f7068702d72657374736572766963652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/abhilashpujari/php-restservice)

Simple PHP Client library that makes it easy to make REST API calls. It uses [Guzzle Client](http://docs.guzzlephp.org/en/stable/) as a dependencies

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

[](#installation)

The recommended way to install this library is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version of this library:

```
php composer.phar require abhilashpujari/php-restservice dev-master
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

You can then later update this library using composer:

```
php composer.phar update
```

Usage
-----

[](#usage)

1 GET Request

```
use RestService\RestService;

$restService = new RestService();
$response = $restService
    ->setEndpoint('https://jsonplaceholder.typicode.com')
    ->get('/posts/1');
```

Note: You can also use `RestService::getInstance()` to get an Instance of the class to use. This elimiated the calling for `new` inside your code. This will always return a new Instance. Singleton pattern is currently not supported.

2 POST Request

```
$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->post('/posts');
```

3 PUT Request

```
$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->put('/posts/1',
         [
             'id' => 1,
             'text' => 'Test'
         ]
     );
```

4 PATCH Request

```
$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->patch('/posts/1',
         [
             'id' => 1,
             'text' => 'Test'
         ]
     );
```

5 DELETE Request

```
$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->delete('/posts/1');
```

6 A fire and forget request which is useful in scenario where we fire the request and aren't concerned of the response, it can be done by setting setIsFireAndForget(true)

```
$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->setIsFireAndForget(true)
     ->post('/posts');
```

7 Request with some custom headers, , it can be done by setting setRequestHeaders(headers array)

```
$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->setRequestHeaders([
         'auth' => 'somevalue'
     ])
     ->post('/posts');
```

Note: to set Authorization header for all requests, you can use `setAuthorizationHeader($token)`. This will require the token to be with the `Bearer ` preceding the actual token.

8 Request in which we request the response data which includes status code, headers, body etc, which can be done by setting request method 4th parameter to false

```
$response = $restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->get('/posts/1', [], [], false);

 var_dump($response->getHeaders());
 var_dump($response->getBody());
```

9 PURGE Request (Can be used for cache invalidation Eg:: varnish, nginx cache)

```
use RestService\RestService;

$restService = new RestService();
$response = $restService
    ->setEndpoint('https://jsonplaceholder.typicode.com')
    ->purge('/posts/1');
```

### License

[](#license)

This project is licensed under the MIT License

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 69.6% 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 ~251 days

Recently: every ~440 days

Total

8

Last Release

1178d ago

PHP version history (4 changes)v1.0PHP &gt;= 5.4

v1.0.4PHP &gt;= 5.5

v1.0.5PHP &gt;= 5.6

1.1.0PHP &gt;= 7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/d1fe6824fa3ef29f0284a7dddd5233ee261e0e1e41a575e6d867e34428b70386?d=identicon)[BennetPHP](/maintainers/BennetPHP)

---

Top Contributors

[![abhilashpujari](https://avatars.githubusercontent.com/u/8478346?v=4)](https://github.com/abhilashpujari "abhilashpujari (39 commits)")[![bennetgallein](https://avatars.githubusercontent.com/u/15325891?v=4)](https://github.com/bennetgallein "bennetgallein (8 commits)")[![abhilashwebnapp](https://avatars.githubusercontent.com/u/8745510?v=4)](https://github.com/abhilashwebnapp "abhilashwebnapp (6 commits)")[![bennet-esyoil](https://avatars.githubusercontent.com/u/48118908?v=4)](https://github.com/bennet-esyoil "bennet-esyoil (3 commits)")

---

Tags

httpphpclientrestcurlhttp client

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bennetgallein-php-restservice/health.svg)

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

###  Alternatives

[zoonman/pixabay-php-api

PixabayClient is a PHP HTTP client library to access Pixabay's API

3354.7k](/packages/zoonman-pixabay-php-api)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[opgg/riotquest

RiotQuest, PHP RiotAPI client library that focused on multi request from OP.GG

172.6k](/packages/opgg-riotquest)

PHPackages © 2026

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