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

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

terranc/yii2-softdelete
=======================

Soft delete extension for Yii2 framework

0.2(1y ago)01MITPHPPHP &gt;=5.5.0

Since Sep 9Pushed 7mo agoCompare

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

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

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

[](#yii2-softdelete)

> Thanks to the original

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 terranc/yii2-softdelete

```

Usage
-----

[](#usage)

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

Edit model class:

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

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

Change database table structures, add `deleted_at (timestamp)` field.

API
---

[](#api)

### ActiveRecord class (SoftDelete Trait):

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

find系列方法会返回 `yiithings\softdelete\ActiveQuery` 对象。

- softDelete() 使用软删除模式删除数据
- forceDelete() 使用物理删除模式强制删除数据
- restore() 恢复被软删除的模型数据
- isTrashed() 是否被软删除

以下命令分别是 `find()` / `findOne()` / `findAll()` 在不同模式下的对应版本：

所有模型（包括被软删除的）：

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

只查找被软删除的模型：

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

以下的命令均被重写成软删除版本：

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

### yiithings\\softdelete\\ActiveQuery

[](#yiithingssoftdeleteactivequery)

增加了 `withTrashed()`, `withoutTrashed()` 和 `onlyTrashed()` 三个方法， 设置相应的查找模式。

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance51

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% 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 ~0 days

Total

2

Last Release

610d ago

### Community

Maintainers

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

---

Top Contributors

[![terranc](https://avatars.githubusercontent.com/u/224353?v=4)](https://github.com/terranc "terranc (6 commits)")[![panlatent](https://avatars.githubusercontent.com/u/4393268?v=4)](https://github.com/panlatent "panlatent (4 commits)")

---

Tags

yii2extensionsoftdelete

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/terranc-yii2-softdelete/health.svg)](https://phpackages.com/packages/terranc-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)
