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

ActiveYii2-behavior

sbilyalov/yii2-softdelete
=========================

Soft delete behavior for Yii2 framework

1.0.0(10y ago)32951PHP

Since Mar 23Pushed 10y agoCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Yii2 Soft Delete
================

[](#yii2-soft-delete)

This behaviour added soft-delete functionality to your active record

\##Installation

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

Run:

```
php composer.phar require  --prefer-dist sbilyalov/yii2-softdelete "*"

```

or add

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

```

to your `composer.json` file.

Usage
-----

[](#usage)

```
use sbilyalov\yii2\behaviors\SoftDelete;

public function behaviors ()
{
    return [
        SoftDeleteBehavior::className()
    ];
}
```

By default the SoftDelete behavior fills the `is_deleted` attribute with the number - 1

If your attribute names are different or you want to use a different way of mark deleted record you may configure the \[\[attribute\]\] and \[\[value\]\] properties like the following:

```
use sbilyalov\yii2\behaviors\SoftDelete;
use yii\db\Expression;

public function behaviors ()
{
    return [
        [
            'class' => SoftDeleteBehavior::className(),
            'attribute' => 'deleted_time',
            'value' => new Expression('NOW()'),
            'restoreValue' => null
        ]
    ];
}
```

Additional functions for active record model
--------------------------------------------

[](#additional-functions-for-active-record-model)

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

// delete soft-deleted model from database
$model->forceDelete();

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

// call SoftDelete::remove()
$model->delete();
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

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

Unknown

Total

1

Last Release

3703d ago

### Community

---

Top Contributors

[![sbilyalov](https://avatars.githubusercontent.com/u/978380?v=4)](https://github.com/sbilyalov "sbilyalov (2 commits)")[![sbilyalov-ideas](https://avatars.githubusercontent.com/u/4262690?v=4)](https://github.com/sbilyalov-ideas "sbilyalov-ideas (2 commits)")

### Embed Badge

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

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

PHPackages © 2026

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