PHPackages                             the-real-start/yii2-jsend-response - 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. the-real-start/yii2-jsend-response

ActiveYii2-extension[API Development](/categories/api)

the-real-start/yii2-jsend-response
==================================

Small set of tools to help work with JSend specifications (see https://labs.omniti.com/labs/jsend). Package is done for yii2 framework and yii2-oauth2-server. Package was build to simplify bilding response for API using this tools.

v0.1.4(9y ago)03171MITPHP

Since May 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/TheRealStart/yii2-jsend-response)[ Packagist](https://packagist.org/packages/the-real-start/yii2-jsend-response)[ Docs](https://github.com/TheRealStart/yii2-jsend-response)[ RSS](/packages/the-real-start-yii2-jsend-response/feed)WikiDiscussions master Synced 4w ago

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

Описание
--------

[](#описание)

Генерация ответов сервера в формате JSend (see ). Package содержит следующие классы:

#### TRS\\RestResponse\\interfaces

[](#trsrestresponseinterfaces)

TemplateInterface

#### TRS\\RestResponse\\templates

[](#trsrestresponsetemplates)

BaseTemplate

#### TRS\\RestResponse\\jsend

[](#trsrestresponsejsend)

Response

Пример
------

[](#пример)

```
// your template class
// templates needs for formating data section in response (remove some data for example)
use TRS\RestResponse\templates\BaseTemplate
class ProductSmallTemplate extends BaseTemplate
{
    protected function prepareResult()
        {
            $this->result = [
                'id'          => $this->model->id,
                'title'       => $this->model->title,
                'description' => $this->model->description,
                // exclude other fields (prices, discounts etc.)
            ];
        }
}

// model
class Product extends BaseProduct
{
    // you can use any other method name
    public function getAsArray($template = 'small')
        {
            if ($template == 'small') {
                $template = new ProductSmallTemplate($this);
            } else {
                throw new \InvalidArgumentException('Invalid template "' . $template . '"');
            }
            return [ 'Product' => $template->getAsArray() ];
        }
}

// controller
use TRS\RestResponse\jsend\Response
class ProductsController extends BaseController
{
    public function actionShow($id)
    {
        $product = Product::find()->localized()->andWhere(['id' => $id])->one();
        Response::success($product->getAsArray('small'))->send();
    }
}
```

Установка
---------

[](#установка)

Для того чтобы установить пакет через composer необходимо в вашем `composer.json` указать дополнительный источник (так как данный пакет не лежит в открытом доступе), и указать сам пакет.

```
...
"require": {
...
	"the-real-start/yii2-jsend-response": "*"
}
...

```

Или установить через консоль:

```
composer require the-real-start/yii2-jsend-response

```

После установки все классы расширения доступны по namespace-у `TRS\RestResponse`.

Документация
------------

[](#документация)

Код по возможности был хорошо задокументирован и позволяет сформировать читабельный `phpdoc`.

Вкратце опишу как сгенерировать документацию.

### Генерация phpdoc

[](#генерация-phpdoc)

Комманда для геренации документации по коду:

```
phpdoc run -d ./ -t doc/ -i vendor/

```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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

Total

5

Last Release

3597d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/484070b5d993e3b019b1ba0825a83a253311ca35f909f309a597f9df8bb959a6?d=identicon)[the-real-start](/maintainers/the-real-start)

---

Tags

extensionyiijsend

### Embed Badge

![Health badge](/badges/the-real-start-yii2-jsend-response/health.svg)

```
[![Health](https://phpackages.com/badges/the-real-start-yii2-jsend-response/health.svg)](https://phpackages.com/packages/the-real-start-yii2-jsend-response)
```

###  Alternatives

[conquer/services

Yii2 soap wsdl web services

1633.8k](/packages/conquer-services)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1143.6k1](/packages/skeeks-yii2-google-api)[apexwire/yii2-restclient

Tools to use API as ActiveRecord for Yii2

133.5k](/packages/apexwire-yii2-restclient)

PHPackages © 2026

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