PHPackages                             yetopen/yii2-models-sorting - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yetopen/yii2-models-sorting

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

yetopen/yii2-models-sorting
===========================

Sorting active record models (grid, form, code)

2.0.1(7y ago)018BSD-3-ClausePHPPHP &gt;=7.0

Since May 12Pushed 7y ago2 watchersCompare

[ Source](https://github.com/YetOpen/yii2-models-sorting)[ Packagist](https://packagist.org/packages/yetopen/yii2-models-sorting)[ RSS](/packages/yetopen-yii2-models-sorting/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Active Record sorting for Yii2
==============================

[](#active-record-sorting-for-yii2)

Sorting active record models (grid, form, code) by field. Automaticaly update sort index. Drag&amp;Drop and etc.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist matthew-p/yii2-models-sorting "@dev"

```

or add

```
"matthew-p/yii2-models-sorting": "@dev"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by:

Add sort column to gridview, if needed (Drag&amp;drop attached to first "td" in "tr"):

```
GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel'  => $searchModel,
    'columns'      => [
        ['class' => 'yii\grid\SerialColumn'],

        'id',
        'title',
        // Sort column
        [
            'class'      => \MP\ARSorting\ARSortColumn::class,
            'attribute'  => 'sort',
            'hideColumn' => false,
        ],
        [
            'attribute' => 'created_at',
            'format'    => ['date', 'format' => 'php: d/m/Y H:i:s'],
        ],

        ['class' => 'yii\grid\ActionColumn'],
    ],
]);
```

Add action in controller (only for gridview sorting):

```
class SampleController extends Controller
{
...
    public function actions(): array
    {
        return array_merge(parent::actions(), [
            'mp-ar-sort' => \MP\ARSorting\ARSortAction::class,
        ]);
    }
...
}
```

Add behavior to AR model:

```
class SampleModel extends ActiveRecord
{
    ...
    /**
     * @inheritdoc
     */
    public function behaviors(): array
    {
        return [
            [
                'class'          => \MP\ARSorting\ARSortBehavior::class,
                'attribute'      => 'sort',
                // Optional
                'queryCondition' => function ($query, self $model) {
                    $query->andWhere(['parent_id' => $model->parent_id]);
                },
            ],
        ];
    }
    ...
}
```

Define encryption key in params.php:

```
'MPARSort' => [
    'encryptionKey' => 'RandomKey',
],

or

'MPComponents' => [
    'encryptionKey' => 'RandomKey',
],

```

That's all. Check it.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 84.6% 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 ~102 days

Total

4

Last Release

2613d ago

Major Versions

1.0.1 → 2.0.02019-03-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a11b10bd765d5709a772c85ead17f8643e15c7cea3ed0ba4660a1cc9032d23a?d=identicon)[maxxer](/maintainers/maxxer)

![](https://www.gravatar.com/avatar/6a00efa7e0d4e4e2eea12617103bb6819687cfe517c3fe5b2bd0addae5fbfd14?d=identicon)[yetopen-stage](/maintainers/yetopen-stage)

![](https://www.gravatar.com/avatar/0544a8c62bb0286fe7f4b507dd7c0a0b851f5d06b71da46c9f9d45e21f05fc31?d=identicon)[yetopen-com](/maintainers/yetopen-com)

---

Top Contributors

[![MatthewPattell](https://avatars.githubusercontent.com/u/10459911?v=4)](https://github.com/MatthewPattell "MatthewPattell (11 commits)")[![maxxer](https://avatars.githubusercontent.com/u/240201?v=4)](https://github.com/maxxer "maxxer (2 commits)")

---

Tags

modelgridrecordyii2extensionmodelsformactivesortingargridview

### Embed Badge

![Health badge](/badges/yetopen-yii2-models-sorting/health.svg)

```
[![Health](https://phpackages.com/badges/yetopen-yii2-models-sorting/health.svg)](https://phpackages.com/packages/yetopen-yii2-models-sorting)
```

###  Alternatives

[kotchuprik/yii2-sortable-widgets

Implementation Rubaxa/Sortable for Yii2. Sortable grid view inside.

61132.2k6](/packages/kotchuprik-yii2-sortable-widgets)[himiklab/yii2-sortable-grid-view-widget

Sortable modification of standard Yii2 GridView widget

80351.1k7](/packages/himiklab-yii2-sortable-grid-view-widget)[richardfan1126/yii2-sortable-gridview

Sortable GridView for Yii2

29189.3k](/packages/richardfan1126-yii2-sortable-gridview)[yiister/yii2-advanced-grid

Advanced GridView extension for Yii framework 2

4712.5k](/packages/yiister-yii2-advanced-grid)

PHPackages © 2026

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