PHPackages                             denisok94/yii-helper - 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. [Framework](/categories/framework)
4. /
5. denisok94/yii-helper

ActiveYii2-extension[Framework](/categories/framework)

denisok94/yii-helper
====================

\--

0.0.4(2y ago)020BSD-3-ClausePHP

Since Jun 11Pushed 4w ago1 watchersCompare

[ Source](https://github.com/Denisok94/yii-helper)[ Packagist](https://packagist.org/packages/denisok94/yii-helper)[ RSS](/packages/denisok94-yii-helper/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

Yii2 Helper Class
=================

[](#yii2-helper-class)

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

[](#installation)

Run:

```
composer require --prefer-dist denisok94/yii-helper
# or
php composer.phar require --prefer-dist denisok94/yii-helper
```

Use
---

[](#use)

- [StatusController](#statuscontroller)
- [ConsoleController](#consolecontroller)
- [Helper](#helper)

StatusController
----------------

[](#statuscontroller)

For communication in the json format.

MethodParametersdefault codeDescriptionsend$data200custom responsessendSuccess$data200Report SuccesssendResponse$data, $message, $status, $code200custom responsessendError$message, $status, $code400Report an errorsendBadRequest$message400sendUnauthorized$message401sendForbidden$message403sendNotFound$message404sendInternalServerError$message500getPost$name--Получить параметр из сообщенияsuccess$data--outdatederror$error, $text, $data--outdated```
namespace app\controllers;
use \denisok94\helper\yii2\StatusController;

class MyController extends StatusController
{
    // code
}
```

```
// получить все данные
$message = $this->post; // array
// получить параметр из данных
$phone = $this->getPost('phone'); // phone or null
```

Report Success

```
// Сообщить об успешной обработки
return $this->sendSuccess(); // http status code 200
// ['code' => '200', 'status' => 'OK', 'data' => []];
// Вернуть результат работы
return $this->sendSuccess($data);  // http status code 200
// ['code' => '200', 'status' => 'OK', 'data' => $data];
```

Report an error

```
return $this->sendError(); // http status code 400
// ['code' => '400', 'status' => 'FAIL', 'message' => 'Error', 'data' => []]
return $this->sendError($message); // http status code 400
// ['code' => '400', 'status' => 'FAIL', 'message' => $message, 'data' => []]
return $this->sendError($message, $data); // http status code 400
// ['code' => '400', 'status' => 'FAIL', 'message' => $message, 'data' => $data]
return $this->sendError($message, $data, 401); // http status code 401
// ['code' => '401', ...]

// return ['code', 'status', 'message'];
return $this->sendBadRequest(); // http status code 400
return $this->sendUnauthorized(); // http status code 401
return $this->sendForbidden(); // http status code 403
return $this->sendNotFound(); // http status code 404
return $this->sendInternalServerError(); // http status code 500

if (!$this->post) {
    return $this->sendBadRequest("Request is null"); // http status code 400
    // ['code' => '400', 'status' => 'FAIL', 'message' => 'Request is null']
}

try {
    //code...
} catch (\Exception $e) {
    return $this->sendInternalServerError($e->getMessage()); // http status code 500
    // ['code' => '500', 'status' => 'FAIL', 'message' => '...']
}
```

Custom response format

```
return $this->send([...]); // http status code 200
// [...];
return $this->send(['code' => 204]); // http status code 204
// ['code' => '204'];
return $this->send(['code' => 201, 'data' => $data]); // http status code 201
// ['code' => '201', 'data' => $data];

return $this->sendResponse($data); // http status code 200
// ['code' => '200', 'status' => 'OK', 'message' => '', 'data' => $data]
return $this->sendResponse($data, $message); // http status code 200
// ['code' => '200', 'status' => 'OK', 'message' => $message, 'data' => $data]
return $this->sendResponse($data, $message, $status, 999); // http status code 999
// ['code' => '999', 'status' => $status, 'message' => $message, 'data' => $data]
```

ConsoleController
-----------------

[](#consolecontroller)

```
namespace app\commands;
use \denisok94\helper\yii2\ConsoleController;

class MyController extends ConsoleController
{
    // code
}
```

Вызвать `action` консольного контроллера:

```
use \denisok94\helper\yii2\Helper as H;
H::exec('controller/action', [params]);
```

> Консольный контроллер, не подразумевает ответ. Вся выводящая информация (echo, print и тд) будет записана в лог файл. При вызове через `H::exec()`, по умолчанию логи находятся в `/runtime/logs/consoleOut.XXX.log` (можно переопределить)

Получить переданные параметры

```
$init = $this->params;
```

Пример:

```
namespace app\commands;
use \denisok94\helper\yii2\ConsoleController;

class MyController extends ConsoleController
{
    public function actionTest()
    {
        $init = $this->params; // ['test' => 'test1']
        $test = $this->params['test']; // 'test1'
    }
}
//
use \denisok94\helper\yii2\Helper as H;
H::exec('my/test', ['test' => 'test1']);
```

Helper
------

[](#helper)

```
use \denisok94\helper\yii2\Helper as H;
H::methodName($arg);
```

`yii2\Helper` наследует все от [Helpers](https://github.com/Denisok94/helper)

MethodDescriptionexecВыполнить консольную команду

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance61

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

Total

4

Last Release

758d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59793012?v=4)[Денис](/maintainers/Denisok94)[@Denisok94](https://github.com/Denisok94)

---

Top Contributors

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

---

Tags

yii2-extensionyii2-extension

### Embed Badge

![Health badge](/badges/denisok94-yii-helper/health.svg)

```
[![Health](https://phpackages.com/badges/denisok94-yii-helper/health.svg)](https://phpackages.com/packages/denisok94-yii-helper)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13926.0k66](/packages/skeeks-cms)[yiisoft/yii2-app-basic

Yii 2 Basic Project Template

6781.8M8](/packages/yiisoft-yii2-app-basic)[devanych/yii2-cart

Shopping cart for Yii2

2011.8k](/packages/devanych-yii2-cart)[yii2-extensions/franken-php

Supercharge your Yii2 applications with FrankenPHP blazing-fast HTTP server.

243.4k](/packages/yii2-extensions-franken-php)

PHPackages © 2026

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