PHPackages                             reliv/rcm-api-lib - 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. reliv/rcm-api-lib

ActiveLibrary[API Development](/categories/api)

reliv/rcm-api-lib
=================

Rcm Api Library

0.12.1(7y ago)07482BSD-3-ClausePHPPHP &gt;=7

Since Jul 6Pushed 7y ago11 watchersCompare

[ Source](https://github.com/reliv/rcm-api-lib)[ Packagist](https://packagist.org/packages/reliv/rcm-api-lib)[ Docs](https://github.com/reliv/rcm-api-lib)[ RSS](/packages/reliv-rcm-api-lib/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (59)Used By (0)

Rcm Api Lib
===========

[](#rcm-api-lib)

API basic response library making use of Middleware (like Zend Expressive) OR ZF2's MVC framework

Makes it easy to quickly create a common API data format.

Include a JavaScript (Angular.JS) library for the client.

##### Several types of common error message types are supported:

[](#several-types-of-common-error-message-types-are-supported)

- Array
- Exception
- HttpStatusCode
- InputFilter (Zend)
- String
- Custom types can also be injected

### EXAMPLE: Middleware (like Zend Expressive)

[](#example-middleware-like-zend-expressive)

```
// From a Middleware that extends Reliv\RcmApiLib\Middleware\AbstractJsonController

    /** EXAMPLE: InputFilter (Zend)  **/
    public function __invoke(
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next
    ) {
        $inputFilter = new RcmGoogleAnalyticsFilter();

        $inputFilter->setData($data);

        if (!$inputFilter->isValid()) {
            return $this->getApiResponse(
                [],
                400,
                $inputFilter
            );
        }
    }
```

##### Returns something like:

[](#returns-something-like)

```
{
  "data": [],
  "messages": [
    {
      "type": "inputFilter",
      "source": "validation",
      "code": "error",
      "value": "Some information was missing or invalid on the form. Please check the form and try again.",
      "primary": true,
      "params": [],
      "key": "inputFilter.validation.error"
    },
    {
      "type": "validatorMessage",
      "source": "my-value",
      "code": "isEmpty",
      "value": "Value is required and can't be empty",
      "primary": null,
      "params": [],
      "key": "validatorMessage.my-value.isEmpty"
    }
  ]
}
```

```
    /** EXAMPLE: General **/
    public function __invoke(
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next
    ) {
        return $this->getApiResponse(
            ['my' => 'response'],
            400,
            new ApiMessage(
                'my-type',
                'my-message-value {my-param}',
                'my-source',
                'my-code',
                true,
                ['my-param' => 'my-value']
            )
        );
    }
```

### EXAMPLE: Zend Framework

[](#example-zend-framework)

```
// From a ZF2 Controller that extends \Reliv\RcmApiLib\Controller\AbstractRestfulJsonController
// @see \Reliv\RcmApiLib\Controller\ExampleRestfulJsonController

    // Add exception message
    $this->addApiMessage(
        new \Exception('Some exception')
    );

    // Add generic message as array
    $this->addApiMessage(
        [
            'key' => 'ArrayError',
            'value' => 'Some {param} Message',
            'primary' => true,
            'type' => 'Array',
            'code' => 'mycode',
            'params' => ['param' => 'array message']
        ]
    );

    // Add generic message as object
    $this->addApiMessage(
        new ApiMessage('MYKEY', 'Some Message')
    );

    // Add HTTP sttus message
    $this->addApiMessage(
        new HttpStatusCodeApiMessage(403)
    );

    // Add inputFilter message
    $inputFilter = new \Zend\InputFilter\InputFilter(); // Use you own inputFilter here
    $this->addApiMessage(
        $inputFilter
    );

    // Return the response
    return $this->getApiResponse(
        null,
        $statusCode = 200,
        $inputFilter,
        true
    );

    // Return the response with your data and no messages
    return $this->getApiResponse(
        ['myThing' => 'someThing'],
    );

```

### Author:

[](#author)

James Jervis Copyright (c) 2015, Reliv' International, Inc.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 76.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 ~24 days

Recently: every ~141 days

Total

58

Last Release

2589d ago

PHP version history (3 changes)0.1.0PHP &gt;=5.5

0.8.0PHP &gt;=5.6

0.11.0PHP &gt;=7

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d89ed9b1fb36217e63fbabed855b75ccbca9a740b8662ed44aa982d5d7c98f7?d=identicon)[reliv](/maintainers/reliv)

---

Top Contributors

[![rodmcnew](https://avatars.githubusercontent.com/u/1828506?v=4)](https://github.com/rodmcnew "rodmcnew (105 commits)")[![jerv13](https://avatars.githubusercontent.com/u/853222?v=4)](https://github.com/jerv13 "jerv13 (16 commits)")[![innaDavis](https://avatars.githubusercontent.com/u/6775475?v=4)](https://github.com/innaDavis "innaDavis (14 commits)")[![bradharms](https://avatars.githubusercontent.com/u/1239044?v=4)](https://github.com/bradharms "bradharms (2 commits)")

---

Tags

apimodulezf2rcmexpressive

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/reliv-rcm-api-lib/health.svg)

```
[![Health](https://phpackages.com/badges/reliv-rcm-api-lib/health.svg)](https://phpackages.com/packages/reliv-rcm-api-lib)
```

###  Alternatives

[evandotpro/edp-github

Github API integration module for Zend Framework 2

241.6k](/packages/evandotpro-edp-github)[narno/gandi-api

Simple PHP library for the Gandi API.

1622.3k](/packages/narno-gandi-api)

PHPackages © 2026

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