PHPackages                             itsmg/rester - 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. [API Development](/categories/api)
4. /
5. itsmg/rester

ActiveLibrary[API Development](/categories/api)

itsmg/rester
============

Laravel package for making rest-apis calls with elegant syntax

v1.0.6(1y ago)10151MITPHPPHP ^8.3

Since Sep 15Pushed 1y ago1 watchersCompare

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

READMEChangelog (7)Dependencies (3)Versions (9)Used By (0)

About Rester
------------

[](#about-rester)

Introducing RESTER, a Laravel package designed to simplify REST API interactions, providing a seamless and elegant way to handle API calls. Inspired by Laravel's Eloquent model approach, this package allows developers to define a model for each API call, mirroring the familiar structure of Laravel's table models.

Furthermore, the package supports grouping related API calls under a common parent class, enhancing code organization and reusability. By encapsulating REST API logic into manageable models, developers can effortlessly integrate external services.

Introduction
------------

[](#introduction)

In this documentation, we'll demonstrate how to use **RESTER** with the example API, **PaynowPaymentGateway**, focusing on the `PayNowCreateOrder` class. With simple and elegant syntax, you can abstract API calls into manageable, reusable objects.

To install the RESTER package, use Composer:

```
composer require itsmg/rester
```

---

1. Making an API Call with Minimal Code
---------------------------------------

[](#1-making-an-api-call-with-minimal-code)

With **RESTER**, you can call an API with as little as one line of code. Here’s how you can fetch an order creation API in the **PaynowPaymentGateway** example:

```
$response = PayNowCreateOrder::fetch();
```

This single line handles everything — from making the request to processing the response. The `PayNowCreateOrder` class encapsulates all the necessary details for the API call.

---

2. Encapsulate API Logic, Focus on Business Logic
-------------------------------------------------

[](#2-encapsulate-api-logic-focus-on-business-logic)

Developers should focus on business logic while **RESTER** handles the API interactions. You can encapsulate API call logic within a separate class, keeping your business logic clean and maintainable.

### Artisan Command to Create API Call Class

[](#artisan-command-to-create-api-call-class)

```
php artisan rester:create --group=PaynowPaymentGateway --api-name=PayNowCreateOrder
```

This command generates a new `PaynowPaymentGatewayBase` &amp; `PayNowCreateOrder` classes under the `app/Rester/PaynowPaymentGateway/` directory (skipping the group folder creation if it already exists).

### Example Base parent Class: PaynowPaymentGatewayBase

[](#example-base-parent-class-paynowpaymentgatewaybase)

```
namespace App\Rester\PaynowPaymentGateway;

use Itsmg\Rester\Rester;
use Itsmg\Rester\Contracts\WithBaseUrl;

class PaynowPaymentGatewayBase extends Rester implements WithBaseUrl
{
    public function setBaseUrl(): string
    {
        return 'https://example-paynow.com/api/v1';
    }
}
```

### Example Class: PayNowCreateOrder

[](#example-class-paynowcreateorder)

```
namespace App\Rester\PaynowPaymentGateway;

use Itsmg\Rester\Rester;
use Itsmg\Rester\Contracts\WithApiRoute;

class PayNowCreateOrder extends PaynowPaymentGatewayBase implements WithApiRoute
{
    public function setApiRoute(): string
    {
        return '/create/order';
    }
}
```

---

3. Assigning Default Payloads for API Calls
-------------------------------------------

[](#3-assigning-default-payloads-for-api-calls)

You can assign default payloads for every request. For instance, when creating an order, you might need to pass amount, currency &amp; userid:

```
class PayNowCreateOrder extends PaynowPaymentGatewayBase implements WithApiRoute, WithDefaultPayload
{
    public function setApiRoute(): string
    {
        return '/create/order';
    }

    public function defaultPayload(): array
    {
       return [
         'user_id' => 'itsbalamg-1606',
         'amount' => '1994.00,
         'currency' => 'USD',
       ];
    }
}
```

Now, every time you call `PayNowCreateOrder`, it automatically sends the default payload unless overridden.

---

4. Assigning Default Headers for API Calls
------------------------------------------

[](#4-assigning-default-headers-for-api-calls)

Headers, like authentication tokens, can be set by default, ensuring they are sent with every request:

```
class PayNowCreateOrder extends PaynowPaymentGatewayBase implements WithApiRoute, WithRequestHeaders
{
    public function setApiRoute(): string
    {
        return '/create/order';
    }

    public function defaultRequestHeaders(): array
    {
       return [
         'Content-Type' => 'application/json',
         'Authorization' => 'Bearer ' . PayNowAuthToken::fetch()
       ];
    }
}
```

Here, the `Authorization` header is automatically attached using an Auth token API call, making the process seamless for developers.

---

5. Dynamic Payload and Header Handling
--------------------------------------

[](#5-dynamic-payload-and-header-handling)

You can easily customize payloads or headers dynamically during runtime. Here’s an example:

### Dynamically Adding Payloads

[](#dynamically-adding-payloads)

```
$response = PayNowCreateOrder::withPayload(['secret-key' => 'xxxxxxx'])
           ->send()
           ->get();
```

### Dynamically Adding Headers

[](#dynamically-adding-headers)

```
$response = PayNowCreateOrder::withHeaders(['Content-Type' => 'application/json'])
           ->send()
           ->get();
```

This flexibility allows you to pass dynamic data and headers depending on your application’s state.

---

6. Exploring RESTER Builder Methods
-----------------------------------

[](#6-exploring-rester-builder-methods)

**RESTER** also provides builder methods for further flexibility:

- **`overWriteEndPoint`**: Overwrite the default endpoint if needed.
- **`appendEndPoint`**: Append additional segments to the endpoint.
- **`assignBaseUri`**: Set a base URI for all API calls.
- **`assignApiRoute`**: Define specific API routes.
- **`setLogStrategy`**: set up your own log strategy by default comes with file log.

These methods give you full control over API URLs as your application's complexity grows.

---

7. Payload and Header Interception
----------------------------------

[](#7-payload-and-header-interception)

RESTER offers a powerful feature to intercept payloads or headers before the API call is fired, making it easy to implement validation rules, caching, or formatting. You can also intercept and modify the response content before returning it to your business logic.

### Example: Intercepting Payload

[](#example-intercepting-payload)

```
class PayNowCreateOrder extends PaynowPaymentGatewayBase implements WithApiRoute, PayloadInterceptor
{
    public function setApiRoute(): string
    {
        return '/create/order';
    }

    public function interceptPayload($payload): array
    {
       $this->exampleValidator($payload);

       return [
         'encrypted-data' => $this->exampleEncryptionLogic($payload)
       ];
    }
}
```

In this example, you can validate and encrypt the payload before it is sent.

---

8. API Access Logging
---------------------

[](#8-api-access-logging)

RESTER includes API access logging. You can enable or disable it using the `$log` property and specify what details should be logged.

```
class PayNowCreateOrder extends PaynowPaymentGatewayBase implements WithApiRoute
{
    protected bool $log = true;

    public function setApiRoute(): string
    {
        return '/create/order';
    }
}
```

This feature allows you to track API interactions for debugging or auditing purposes.

---

Conclusion
----------

[](#conclusion)

With **RESTER**, API integration in Laravel becomes a breeze. Whether you're sending dynamic payloads, managing authentication, or logging API access, RESTER allows you to focus on your business logic by abstracting the complexity of REST API calls into reusable, manageable components.

---

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within Rester, please send an e-mail to Balamurugan via [balaneutro@gmail.com ](mailto:balaneutro@gmail.com). All security vulnerabilities will be promptly addressed.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance43

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

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 ~25 days

Total

7

Last Release

457d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.0.4PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/94d2311d5f5d4251880a4b58a898864090071e620a414c8b7fcba5be5a18773d?d=identicon)[balamg](/maintainers/balamg)

---

Top Contributors

[![balamgit](https://avatars.githubusercontent.com/u/40624572?v=4)](https://github.com/balamgit "balamgit (27 commits)")

### Embed Badge

![Health badge](/badges/itsmg-rester/health.svg)

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

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

805.7M125](/packages/saloonphp-laravel-plugin)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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