PHPackages                             ereminmdev/yii2-crud - 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. [Admin Panels](/categories/admin)
4. /
5. ereminmdev/yii2-crud

ActiveYii2-extension[Admin Panels](/categories/admin)

ereminmdev/yii2-crud
====================

Crud module for Yii framework.

v1.1.289(2mo ago)13.4kMITPHPPHP &gt;=7.4

Since Nov 19Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ereminmdev/yii2-crud)[ Packagist](https://packagist.org/packages/ereminmdev/yii2-crud)[ Docs](https://github.com/ereminmdev/yii2-crud)[ RSS](/packages/ereminmdev-yii2-crud/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (321)Used By (0)

yii2-crud
=========

[](#yii2-crud)

Crud module for Yii framework.

Install
-------

[](#install)

`composer require --prefer-dist ereminmdev/yii2-crud`

Use
---

[](#use)

1. Add Crud module to config file:

```
'modules' => [
    'crud' => [
        'class' => 'ereminmdev\yii2\crud\Crud',
    ],
],

```

2. Add crudConfig() static function to ActiveRecord model:

```
public static function crudConfig()
{
    return [
        'title' => Yii::t('app', 'Products'),
    ],
}

```

More options:

```
public static function crudConfig()
{
    return [
        'title' => Yii::t('app', 'Products'),
        'dataProvider' => function (ActiveDataProvider $dataProvider) {
            $dataProvider->sort = [
                'defaultOrder' => [
                    'title' => SORT_ASC,
                ],
            ];
            if ($dataProvider->pagination) {
                $dataProvider->pagination->pageSize = 50;
            }
            if (!Yii::$app->user->can('admin')) {
                $dataProvider->query->andWhere(['or', ['role' => array_keys(User::roles())], ['id' => Yii::$app->user->id]]);
            }
        },
        'gridShowColumns' => ['title', 'image'],
        'gridHideColumns' => ['content'],
        'gridEditLinkField' => 'id',
        'gridColumns' => [
            'title' => [
                'attribute' => 'title',
                'label' => 'Title',
                'value' => fn(self $model) => $model->getBrandTitle() . ' ' . $model->title,
            ],
            'colors1' => false,
        ],
        'formFields' => [
            'colors' => fn(ActiveForm $form, self $model) => $form->field($model, 'sizes')->checkboxList(static::colors()),
            'colors2' => false,
        ],
        'columnsSchema' => [
            'shop_phone' => ['type' => 'tel', 'labelHint' => 'User phone number'],
            'shop_email' => ['type' => 'email'],
            'shop_url' => ['type' => 'url'],
            'brand_id' => [
                'type' => 'relation',
                'rtype' => 'hasOne',
                'relation' => 'brand',
                'getList' => fn() => Brand::find()
                    ->select(['title', 'id'])
                    ->orderBy(['title' => SORT_ASC])
                    ->indexBy('id')
                    ->column(),
            ],
            'sizes' => [
                'type' => 'relation',
                'rtype' => 'hasMany',
                'relation' => 'sizes',
            ],
            'status' => [
                'type' => 'array',
                'itemList' => fn() => static::statuses(),
                'gridDropButton' => true,
                'formFieldInputType' => 'radioList',
            ],
            'comment' => ['jsEditPrompt' => true],
            'colors3' => false,
        ],
        'gridToolbarActions' => [
            '{custom}' => Html::a('Моя кнопка', '#', ['class' => 'btn btn-default']),
        ],
        'gridActions' => [
            '{custom}' => fn(self $model, mixed $key, Crud $crud) => [
                'label' => 'Мое действие',
                'url' => '#',
            ],
        ],
        'controller.behaviors' => [
            'access' => [
                'class' => AccessControl::class,
                'rules' => [
                    [
                        'actions' => ['index'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                    [
                        'actions' => ['create', 'update'],
                        'allow' => true,
                        'roles' => ['admin'],
                    ],
                ],
            ],
        ],
        'views.index.h1' => fn(Crud $crud, View $view) => '' . Html::encode($view->title) . '',
        'access.save' => false, // hide Create, Save and Update buttons
        'access.edit' => true, // can edit
        'access.delete' => false, // hide Delete button
    ];
}

```

Set only view for specific users:

```
if (!Yii::$app->user->can('admin')) {
    $config['gridToolbarTemplate'] = '';
    $config['gridActionsTemplate'] = '';
    $config['gridCheckboxColumn'] = false;
    $config['gridActionColumn'] = false;
    $config['access.save'] = false;
    $config['access.edit'] = false;
    $config['access.delete'] = false;
}

```

Set tree view:

```
public static function crudConfig()
{
    return [
        // ...
        'viewAs' => 'tree', // enable tree as default index view
        'tree' => [
            'parentField' => 'parent_id',
            'childrenRelation' => 'children',
            'sortField' => 'position', // false - disable sorting
            'itemActionsTemplate' => "{custom}\n{--}\n{create1}\n{create2}\n{--}",
            'itemActions' => [
                '{custom}' => fn(self $model, DefaultController $controller, Crud $crud) => [
                    'label' => 'Custom label',
                    'url' => ['#'],
                ],
            ],
            'titleBlock' => fn(self $model, DefaultController $controller, Crud $crud) => Html::encode($model->title),
            'titleBlock_text' => fn(self $model, DefaultController $controller, Crud $crud) => Html::encode($model->name),
            'titleBlock_options' => fn(self $model, DefaultController $controller, Crud $crud) => ['class' => 'red'],
            'titleBlock_onHover' => fn(self $model, DefaultController $controller, Crud $crud) => Html::encode($model->statusText),
            'rightBlock' => fn(self $model, DefaultController $controller, Crud $crud) => $model->status,
        ],
    ];
}

```

3. Insert link into view:

```

```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance85

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

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

Total

320

Last Release

75d ago

PHP version history (3 changes)v1.0.0PHP &gt;=5.4.0

v1.0.28PHP &gt;=7.0

v1.1.226PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7615c0d5af4d783b3dcb37116fcfcb0607862dd9ba30eb82ab9cf3b74879d91?d=identicon)[ereminmdev](/maintainers/ereminmdev)

---

Top Contributors

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

---

Tags

yii2modulecrud

### Embed Badge

![Health badge](/badges/ereminmdev-yii2-crud/health.svg)

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

###  Alternatives

[schmunk42/yii2-giiant

Gii CRUD generator for Yii 2 Framework

269471.5k17](/packages/schmunk42-yii2-giiant)

PHPackages © 2026

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