PHPackages                             fgsl/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. [HTTP &amp; Networking](/categories/http)
4. /
5. fgsl/rest

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

fgsl/rest
=========

Fgsl RESTful Requester

1.5.1(1y ago)086AGPL-3.0-onlyPHPPHP &gt;=8.2

Since Oct 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/fgsl/rest)[ Packagist](https://packagist.org/packages/fgsl/rest)[ Docs](https://github.com/fgsl/rest)[ RSS](/packages/fgsl-rest/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (22)Used By (0)

FGSL rest
=========

[](#fgsl-rest)

Component to make HTTP requests and test RESTful APIs

How to install
--------------

[](#how-to-install)

```
composer require fgsl/rest
```

How to instance
---------------

[](#how-to-instance)

```
use Fgsl\Rest\Rest;

$rest = new Rest();
```

### Available methods

[](#available-methods)

- **doGet**

```
/**
     * Method to make a HTTP GET request
     * @param $headers array
     * @param $url string
     * @param $expectedCode string | integer | array
     */
    public function doGet($headers,$url,$expectedCode, $data = [],$verbose=false)
```

- **doPost**

```
/**
     * Method to make a HTTP POST request
     * @param $data array
     * @param $headers array
     * @param $url string
     * @param $expectedCode string | integer | array
     */
    public function doPost($data,$headers,$url,$expectedCode, $verbose=false)
```

- **doPut**

```
    /**
     * Method to make a HTTP PUT request
     * @param $data array
     * @param $headers array
     * @param $url string
     * @param $expectedCode string | integer | array
     */
    public function doPut($data,$headers,$url,$expectedCode, $verbose=false) {
```

- **doDelete**

```
/**
     * Method to make a HTTP DELETE request
     * @param $headers array
     * @param $url string
     * @param $expectedCode string | integer | array
     * @param $data array
     * @param $verbose boolean
     */
    public function doDelete($headers,$url,$expectedCode, $data = [],$verbose=false)
```

- **doPatch**

```
/**
     * Method to make a HTTP PATCH request
     * @param $data array
     * @param $headers array
     * @param $url string
     * @param $expectedCode string | integer | array
     */
    public function doPatch($data,$headers,$url,$expectedCode, $verbose=false)
```

- **doDelete**

```
/**
     * Method to make a HTTP PATCH request
     * @param $data array
     * @param $headers array
     * @param $url string
     * @param $expectedCode string | integer | array
     */
    public function doPatch($data,$headers,$url,$expectedCode, $verbose=false)
```

### Examples

[](#examples)

Below we have some examples about how to use the `Rest` class.

We have used a page of the [Brazilian National Observatory](https://www.gov.br/observatorio/pt-br) for GET method.

We have used [Reqres](https://reqres.in/) for POST, PATCH and DELETE methods.

Testing a HTTP GET request
--------------------------

[](#testing-a-http-get-request)

```
public function testGet()
    {
        $rest = new Rest();
        $this->assertTrue(is_object($rest));

        @$response = $rest->doGet([],'http://www.horalegalbrasil.mct.on.br/SincronismoPublico.html',200);

        $this->assertStringContainsString('Sincronismo', $response);

        @$response = $rest->doGet([],'http://www.horalegalbrasil.mct.on.br/SincronismoPublico.html',500);

        $this->assertEquals(1,count($rest->requestErrors));

        $this->assertEquals(2,$rest->requestCounter);
    }
```

Testing a HTTP POST request
---------------------------

[](#testing-a-http-post-request)

```
public function testPost()
    {
        $rest = new Rest();

        $data = [
            'name' => 'morpheus',
            'job' => 'leader'
        ];

        @$response = $rest->doPost($data, [],'https://reqres.in/api/users',201);

        $this->assertStringContainsString('createdAt', $response);
    }
```

### Testing a HTTP PUT request

[](#testing-a-http-put-request)

```
    public function testPut()
    {
        $rest = new Rest();

        $data = [
            'name' => 'morpheus',
            'job' => 'general'
        ];

        @$response = $rest->doPut($data, [],'https://reqres.in/api/users/2',201);

        $this->assertStringContainsString('updatedAt', $response);
    }
```

Testing a HTTP PATCH request
----------------------------

[](#testing-a-http-patch-request)

```
public function testPatch()
    {
        $rest = new Rest();

        $data = [
            'name' => 'morpheus',
            'job' => 'zion resident'
        ];

        @$response = $rest->doPatch($data, [], 'https://reqres.in/api/users/2', 200);

        $this->assertStringContainsString('updatedAt', $response);
    }
```

Testing a HTTP DELETE request
-----------------------------

[](#testing-a-http-delete-request)

```
public function testDelete()
    {
        $rest = new Rest();

        @$response = $rest->doDelete([],'https://reqres.in/api/users/2',204);

        $this->assertEquals(0,count($rest->requestErrors));
    }
}
```

You can allow more than one HTTP status code as a valid response. The code snippet below shows a request that allows 200 and 201 status code as valid responses.

```
        @$response = $rest->doGet([],'http://www.horalegalbrasil.mct.on.br/SincronismoPublico.html',[200,201]);

        $this->assertStringContainsString('Sincronismo', $response);
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~38 days

Recently: every ~53 days

Total

10

Last Release

591d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.1

1.4.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cb6d4497d6c4358a5c7e7e31d34412f5d6e9617aafa487b125bcc870171cd1e?d=identicon)[fgsl](/maintainers/fgsl)

---

Top Contributors

[![fgsl](https://avatars.githubusercontent.com/u/128915?v=4)](https://github.com/fgsl "fgsl (17 commits)")

---

Tags

httprequestrest

### Embed Badge

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

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

###  Alternatives

[aplus/http

Aplus Framework HTTP Library

2311.6M10](/packages/aplus-http)[emartech/escher

Library for HTTP request signing (PHP implementation)

20293.8k8](/packages/emartech-escher)[elementaryframework/water-pipe

URL routing framework and requests/responses handler for PHP

254.6k4](/packages/elementaryframework-water-pipe)

PHPackages © 2026

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