PHPackages                             amnah/yii2-classes - 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. amnah/yii2-classes

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

amnah/yii2-classes
==================

Yii2 classes

123.6k3[1 issues](https://github.com/amnah/yii2-classes/issues)PHP

Since Jul 20Pushed 10y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Yii 2 Classes
=============

[](#yii-2-classes)

A various collection of classes. Install using composer `"amnah/yii2-classes": "dev-master"`.

Table of Contents
-----------------

[](#table-of-contents)

- \[Behaviors/SoftDelete\] (#softdelete)
- \[Widgets/ExtListView\] (#extlistview)
- \[Test/DbToDbFixtureManager\] (#dbtodbfixturemanager)

### SoftDelete

[](#softdelete)

This class adds soft-delete functionality to ActiveRecord models.

Before you use this, please see [this response](http://stackoverflow.com/a/2549940) to decide if you really need this functionality.

#### Usage

[](#usage)

- Add column ``delete_time`` (int or timestamp **DEFAULT NULL**) to your database table
- Add behavior to your model

```
public function behaviors() {
    return [
        'softDelete' => [
            'class' => 'amnah\yii2\behaviors\SoftDelete',
            // these are the default values, which you can omit
            'attribute' => 'delete_time',
            'value' => null, // this is the same format as in TimestampBehavior
            'safeMode' => true, // this processes '$model->delete()' calls as soft-deletes
        ],
    ];
}
```

- Call functions

```
// soft-delete model
$model->remove();

// restore model
$model->restore();

// delete model from db
$model->forceDelete();

// soft-delete model if $safeMode = true
// delete model from db if $safeMode = false
$model->delete();
```

- (Optional) Update model by adding default condition/scope to select only non-deleted records

```
class Customer extends ActiveRecord
{
    public static function find()
    {
        return parent::find()->where(['delete_time' => null]);
    }
}
```

### ExtListView

[](#extlistview)

The ExtListView class extends the default `yii\widgets\ListView` class by adding in views and closures.

#### Usage

[](#usage-1)

Using views:

```
// @app/views/list/index.php

```

```
// @app/views/list/_list.php
{summary}
{pager}

    {items}

```

Using closures:

```

```

### DbToDbFixtureManager

[](#dbtodbfixturemanager)

The DbToDbFixtureManager class loads fixtures in from another database instead of from php arrays.

This is useful if you constantly change your db schema. For example, you can simply copy your developmentDb via phpMyAdmin and use that as your fixtureDb - no need to go through several php files and manually update data. From there, it's also easier to manipulate the data when you have sql commands at your disposal.

Additionally, this is useful if you have lots of fixture data. It is significantly faster to copy tables in sql than it is to load arrays in php and manually insert each individual record (which is the current implementation of DbFixtureManager).

**Note:** Currently, the fixtureDb must be on the same db connection as the testDb (same server, user, and password). This is because loads the data by using `insert into `fixtureDb`.`table select * from testDb.table`.

#### Usage

[](#usage-2)

```
// @app/tests/unit/_config.php
'components' => [
    'fixture' => [
        'class' => 'amnah\yii2\test\DbToDbFixtureManager',
        'fixtureDb' => 'databasename_test',
    ],
]
```

```
// @app/tests/unit/models/UserTest.php
protected function setUp() {
    parent::setUp();

    // load fixtures using same exact call
    $this->loadFixtures(['tbl_user']);
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d6704c3ef75e38b07c3086e40a5ac32ffc792eded6396447b123b7852776568?d=identicon)[amnah](/maintainers/amnah)

---

Top Contributors

[![amnah](https://avatars.githubusercontent.com/u/2630503?v=4)](https://github.com/amnah "amnah (16 commits)")[![davidjeddy](https://avatars.githubusercontent.com/u/6232455?v=4)](https://github.com/davidjeddy "davidjeddy (2 commits)")

### Embed Badge

![Health badge](/badges/amnah-yii2-classes/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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