PHPackages                             rahulabs/yii2-softdelete - 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. rahulabs/yii2-softdelete

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

rahulabs/yii2-softdelete
========================

Soft delete extension for Yii2 framework

1.0.1(1y ago)125MITPHPPHP &gt;=5.5.0

Since Aug 6Pushed 1y ago1 watchersCompare

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

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

Yii2 SoftDelete
===============

[](#yii2-softdelete)

Soft delete extension for Yii2 framework.

This extension ensures that soft-deleted has delete native consistent behavior and is IDE-friendly.

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

[](#installation)

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

Either run

```
composer require --prefer-dist rahulabs/yii2-softdelete "*"

```

or add

```
"rahulabs/yii2-softdelete": "*"

```

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

Usage
-----

[](#usage)

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

Edit model class:

```
use rahulabs\softdelete\behaviors\SoftDeleteBehavior;
use rahulabs\softdelete\SoftDelete;

class Model extends \yii\db\ActiveRecord
{
    use SoftDelete;

    public function behaviors()
    {
        return [
            'class' => SoftDeleteBehavior::className(),
        ];
    }
}
```

Change database table structures, add `deleted_at (int 11)` field and attached to UNIQUE index.

API
---

[](#api)

### ActiveRecord class (SoftDelete Trait):

[](#activerecord-class-softdelete-trait)

The find series method will return `rahulabs\softdelete\ActiveQuery` Object.

- softDelete() Deleting data using soft delete mode
- forceDelete() Use physical deletion mode to force delete data
- restore() Recover soft deleted model data
- isTrashed() Whether it is soft deleted

The following commands are `find()` / `findOne()` / `findAll()` Corresponding versions in different modes ：

All models (including soft deleted ones)：

- findWithTrashed()
- findOneWithTrashed($condition)
- findAllWithTrashed($condition)

Find only soft deleted models ：

- findOnlyTrashed()
- findOneOnlyTrashed($condition)
- findAllOnlyTrashed($condition)

The following commands have been rewritten as soft delete versions ：

- find()
- findOne()
- findAll()
- delete()

### rahulabs\\softdelete\\ActiveQuery

[](#rahulabssoftdeleteactivequery)

increased `withTrashed()`, `withoutTrashed()` and `onlyTrashed()` Three methods， Set the corresponding search mode。

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance47

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

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

Total

2

Last Release

392d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4083835b596a398908dd0bc60c9271d78904e1f66400c42b60994f39558722ae?d=identicon)[rahulabstain](/maintainers/rahulabstain)

---

Top Contributors

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

---

Tags

yii2extensionsoftdelete

### Embed Badge

![Health badge](/badges/rahulabs-yii2-softdelete/health.svg)

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

###  Alternatives

[skeeks/cms

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

13825.6k47](/packages/skeeks-cms)

PHPackages © 2026

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