PHPackages                             vivre-tech/rest-renderer - 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. vivre-tech/rest-renderer

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

vivre-tech/rest-renderer
========================

For Yii2: Just like Controller::Action but only for having multiple rendering templates in same place for data models.

1.0.0(8y ago)012.6k↓42.3%1MITPHPPHP &gt;=5.4

Since Dec 14Pushed 8y ago2 watchersCompare

[ Source](https://github.com/VivreTech/rest-renderer)[ Packagist](https://packagist.org/packages/vivre-tech/rest-renderer)[ RSS](/packages/vivre-tech-rest-renderer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

This extension provides the ability to have multiple rendering templates in one place for data models.

For license information check the [LICENSE](LICENSE.md)-file.

[![Latest Stable Version](https://camo.githubusercontent.com/dbcdae545a7edc10b5174c6c69ffe3cc7d17475e4a016a9bf9b699aeed6c1a79/68747470733a2f2f706f7365722e707567782e6f72672f76697672652d746563682f726573742d72656e64657265722f762f737461626c652e706e67)](https://packagist.org/packages/vivre-tech/rest-renderer)[![Total Downloads](https://camo.githubusercontent.com/fa1dec2e1ab4a1aa9b969398ea5fb096af082900a0cce9f063dc5d6e6b89dad2/68747470733a2f2f706f7365722e707567782e6f72672f76697672652d746563682f726573742d72656e64657265722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/vivre-tech/rest-renderer)[![Build Status](https://camo.githubusercontent.com/69f2278b949e268cdea83ba956d4d73bcd104746f7081a4458faf23700809b3b/68747470733a2f2f7472617669732d63692e6f72672f76697672652d746563682f726573742d72656e64657265722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vivre-tech/rest-renderer)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist vivre-tech/rest-renderer

```

or add

```
"vivre-tech/rest-renderer": "*"
```

to the require section of your composer.json.

Usage
-----

[](#usage)

Example:

```
use vivretech\rest\renderer\DataRenderer;

class DummyModelRenderer extends DataRenderer
{

    /**
     * @param array $params
     * @return mixed
     */
    public function renderMain($params = [])
    {
        return [];
    }

    public function renderSummary($model)
    {
        return [
            'name' => $model['name'],
            'price' => $model['price'],
        ];
    }

    public function renderDetailed($model)
    {
        return [
            'id' => $model['id'],
            'name' => $model['name'],
            'price' => $model['price'],
            'created_at' => $model['created_at'],
        ];
    }

}

$render = new DummyModelRenderer();
$productModel = [
    'id' => 1,
    'name' => 'Product 1',
    'price' => 100,
    'created_at' => date('Y-m-d H:i:s')
];

/* Output JSON -> Dummy REST response. */
header("Content-Type: application/json;charset=utf-8");

echo
    json_encode([
        'productSummary' => $render->run('summary', [$productModel]),
        'productDetailed' => $render->run('Detailed', [$productModel]),
    ]);
```

Response
--------

[](#response)

```
{
    "productSummary": {
        "name": "Product 1",
        "price": 100
    },
    "productDetailed": {
        "id": 1,
        "name": "Product 1",
        "price": 100,
        "created_at": "2017-12-14 08:25:06"
    }
}
```

Unit Testing
------------

[](#unit-testing)

If you run the following command: `composer install` in a dev environment then you will find `phpunit` in `/vendor/bin/phpunit`.

In case `phpunit` in not installed via command `composer install`, just fallow next steps:

1. run in console/terminal `brew install phpunit`

To test, in the `root` of the project, base on how `phpunit` is installed you will have two choices to run:

1. installed via command `composer install` you will have to execute in console/terminal: `vendor/bin/phpunit`
2. installed via `bre` you will have to execute in console/terminal: `phpunit`

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3078d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/327b21f2438fba2a3f8b19c9b4cc667773a62b6fa0e61216d38f45d9d4464014?d=identicon)[microThread](/maintainers/microThread)

---

Top Contributors

[![microThread](https://avatars.githubusercontent.com/u/4279940?v=4)](https://github.com/microThread "microThread (3 commits)")

---

Tags

apirestyii2rendererdata-rendererrest-renderer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vivre-tech-rest-renderer/health.svg)

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

###  Alternatives

[hiqdev/yii2-hiart

ActiveRecord for API

5951.8k3](/packages/hiqdev-yii2-hiart)

PHPackages © 2026

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