PHPackages                             razonyang/yii2-jsend - 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. razonyang/yii2-jsend

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

razonyang/yii2-jsend
====================

JSend port for Yii2

1.0.1(6y ago)64.2k1BSD-3-ClausePHP

Since Aug 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/razonyang/yii2-jsend)[ Packagist](https://packagist.org/packages/razonyang/yii2-jsend)[ RSS](/packages/razonyang-yii2-jsend/feed)WikiDiscussions master Synced yesterday

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

JSend port for Yii2
===================

[](#jsend-port-for-yii2)

[![Build Status](https://camo.githubusercontent.com/0dce8c99b319991cc4127e8f22068e984bcd10a8b723832bde85a1c9de00cf2a/68747470733a2f2f7472617669732d63692e6f72672f72617a6f6e79616e672f796969322d6a73656e642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/razonyang/yii2-jsend)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c9cacc3ccccfc3a161f4769c737d25d55c6b315c218821bf28d11706a46c6669/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f72617a6f6e79616e672f796969322d6a73656e642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/razonyang/yii2-jsend/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/2ed1d3eb6447c36fb02eac85272fcf8effc69f0055000dd54e4f2ddaa9d3fa49/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f72617a6f6e79616e672f796969322d6a73656e642f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/razonyang/yii2-jsend/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/46bd7387e6f3a2653c3d4d96f8266dbf5641c55ebe10836c9ad7e7a43b8e7fb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72617a6f6e79616e672f796969322d6a73656e642e737667)](https://packagist.org/packages/razonyang/yii2-jsend)[![Total Downloads](https://camo.githubusercontent.com/669320314c9333972800cf3ca484c3c6288525a6d318e4f7e9f610ddcb59628c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72617a6f6e79616e672f796969322d6a73656e642e737667)](https://packagist.org/packages/razonyang/yii2-jsend)[![LICENSE](https://camo.githubusercontent.com/6308d4002b256dd79574c196b9176c3f8c9164ba0a286c61072d1a15a7b93e4a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f72617a6f6e79616e672f796969322d6a73656e64)](LICENSE)

The package is a Yii2's implementation of [JSend](https://github.com/omniti-labs/jsend) specification.

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

[](#installation)

```
composer require razonyang/yii2-jsend

```

Usage
-----

[](#usage)

Update resposne formater and error handler:

```
return [
    'components' => [
        'response' => [
            'formatters' => [
                \yii\web\Response::JSON => [
                    'class' => \RazonYang\Yii2\JSend\Formatter::class,
                ],
            ],
        ],
        'errorHandler' => [
            'class' => \RazonYang\Yii2\JSend\ErrorHandler::class,
        ],
    ],
];
```

Change you rest controller serializer:

```
public $serializer = \RazonYang\Yii2\JSend\Serializer::class;
```

Error Handler
-------------

[](#error-handler)

`ErrorHandler` converts exception to error payload:

```
{
    "status": "error",
    "code": "exception code",
    "message": "exception message"
}
```

It can also returns the optional data field by throwing a JSend's Exception:

```
throws new RazonYang\Jsend\Exception($message, $code, $data, $previous);

// you can also define your own exception:
class MyException extends RazonYang\Jsend\Exception
{
}

throws new MyException();
```

```
{
    "status": "error",
    "code": "exception code",
    "message": "exception message",
    "data": "exception data"
}
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Every ~0 days

Total

2

Last Release

2456d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17720932?v=4)[Razon Yang](/maintainers/RazonYang)[@razonyang](https://github.com/razonyang)

---

Top Contributors

[![razonyang](https://avatars.githubusercontent.com/u/17720932?v=4)](https://github.com/razonyang "razonyang (2 commits)")

---

Tags

yii2-jsendyii2extensionjsend

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/razonyang-yii2-jsend/health.svg)

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

###  Alternatives

[dotzero/yii2-amocrm

Расширение для Yii Framework 2 реализующее клиент для работы с API amoCRM

1639.7k](/packages/dotzero-yii2-amocrm)[conquer/services

Yii2 soap wsdl web services

1632.5k](/packages/conquer-services)[apexwire/yii2-restclient

Tools to use API as ActiveRecord for Yii2

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

PHPackages © 2026

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