PHPackages                             yii2-webivan1/yii2-validate-action-params - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. yii2-webivan1/yii2-validate-action-params

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

yii2-webivan1/yii2-validate-action-params
=========================================

Extension Yii2

v0.0.2(7y ago)12201[1 PRs](https://github.com/webivan1/validateAction/pulls)MITPHPPHP &gt;=7.0.0CI failing

Since Oct 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/webivan1/validateAction)[ Packagist](https://packagist.org/packages/yii2-webivan1/yii2-validate-action-params)[ RSS](/packages/yii2-webivan1-yii2-validate-action-params/feed)WikiDiscussions master Synced yesterday

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

❗Deprecated
-----------

[](#deprecated)

Ext Yii 2 Validate action params, DI action
===========================================

[](#ext-yii-2-validate-action-params-di-action)

Install
-------

[](#install)

```
composer require yii2-webivan1/yii2-validate-action-params

```

Settings
--------

[](#settings)

Add trait in any controller or global controller for trigger event before runAction

```
    use webivan\validateAction\ValidateActionTrait;
```

Add behavior in controller

```
    public function behaviors()
    {
        return [
            'validation' => [
                'class' => webivan\validateAction\ValidateActionBehavior::class,
                // 'actions' => ['index', 'about'] // Validate only action
            ]
        ];
    }
```

Usage
-----

[](#usage)

### Add types by params action \[php7\]

[](#add-types-by-params-action-php7)

```
    public function actionIndex(int $number, string $name, array $data)
    {
        // ...
    }
```

### Or add phpdoc by action together with tag @validate

[](#or-add-phpdoc-by-action-together-with-tag-validate)

```
    /**
     * @validate
     * @param integer $number
     * @param string $name
     * @param array $data
     */
    public function actionIndex($number, $name, array $data)
    {
        // ...
    }
```

Dependency injection
--------------------

[](#dependency-injection)

### You can add DI in action

[](#you-can-add-di-in-action)

```
    public function actionIndex(Request $request, int $number, string $name, array $data, Response $response)
    {
        // ...
    }
```

### Or phpdoc. Write the full path to the class name!

[](#or-phpdoc-write-the-full-path-to-the-class-name)

```
    /**
     * @validate
     * @param \yii\web\Request $request
     * @param integer $number
     * @param string $name
     * @param array $data
     * @param Response $response
     */
    public function actionIndex($request, $number, $name, $data, Response $response)
    {
        // ...
    }
```

### Add models \[ActiveRecord\]

[](#add-models-activerecord)

```
    // Usually
    public function actionIndex($cityId)
    {
        if (is_null($city = City::findOne(['id' => intval($cityId)]))) {
            throw new HttpExceprion(404);
        }

        return $city;
    }

    // Now
    public function actionIndex(City $city)
    {
        return $city;
    }

    // Or

    /**
     * @validate
     * @param \app\models\City $city
     */
    public function actionIndexNew($city)
    {
        return $city;
    }

    // Or

    /**
     * @validate
     * @param City $city
     */
    public function actionIndexNew(City $city)
    {
        return $city;
    }
```

### User model

[](#user-model)

```
    public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            throw new HttpException(404);
        }

        return true;
    }

    // If user is guest, Error 404
    public function actionIndexNew(User $user)
    {
        // Error 404
    }

    // If user is login, User::findOne(['id' => \Yii::$app->user->id])
    public function actionIndexNew(User $user)
    {
        return $user;
    }
```

### How to change the default query DI?

[](#how-to-change-the-default-query-di)

Add interface `webivan\validateAction\models\IFindItem` in model

### How to change the default column search model?

[](#how-to-change-the-default-column-search-model)

Add interface `webivan\validateAction\models\IFindColumn` in model

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~1 days

Total

6

Last Release

2746d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c4e0aa9875f7dd4999cc3b188522a9f7eea72fe68acd7982bcb15b5fbe5511f?d=identicon)[webivan1](/maintainers/webivan1)

---

Top Contributors

[![IvanMaltsev](https://avatars.githubusercontent.com/u/10236230?v=4)](https://github.com/IvanMaltsev "IvanMaltsev (14 commits)")[![webivan1](https://avatars.githubusercontent.com/u/16155918?v=4)](https://github.com/webivan1 "webivan1 (2 commits)")

---

Tags

yii2action validateinject actionDI action

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yii2-webivan1-yii2-validate-action-params/health.svg)

```
[![Health](https://phpackages.com/badges/yii2-webivan1-yii2-validate-action-params/health.svg)](https://phpackages.com/packages/yii2-webivan1-yii2-validate-action-params)
```

###  Alternatives

[borales/yii2-phone-input

Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget

1341.6M6](/packages/borales-yii2-phone-input)[codeonyii/yii2-at-least-validator

Validates at least one (or more) attributes.

28253.5k1](/packages/codeonyii-yii2-at-least-validator)[arogachev/yii2-many-to-many

Many-to-many ActiveRecord relation for Yii 2 framework

3541.2k4](/packages/arogachev-yii2-many-to-many)[yii2mod/yii2-validators

Collection of useful validators for Yii Framework 2.0

1816.8k](/packages/yii2mod-yii2-validators)

PHPackages © 2026

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