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. [Framework](/categories/framework)
4. /
5. sbilyalov/yii2-softdelete

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

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 4w ago

READMEChangelog (1)Dependencies (1)Versions (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 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

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

3751d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c819c20860527f463b8e2cc078136e3b3e2924b48b32a8ee90b0ed7e597b2cf?d=identicon)[seydamet](/maintainers/seydamet)

---

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)")

---

Tags

yii2Behaviorsoft-deletedelete behavior

### 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)
```

###  Alternatives

[yiisoft/yii2-app-advanced

Yii 2 Advanced Project Template

1.7k960.6k5](/packages/yiisoft-yii2-app-advanced)[yiisoft/yii2-redis

Redis Cache, Session and ActiveRecord for the Yii framework

44912.1M264](/packages/yiisoft-yii2-redis)[yiisoft/yii2-app-basic

Yii 2 Basic Project Template

6761.8M8](/packages/yiisoft-yii2-app-basic)[yiisoft/yii2-apidoc

API Documentation generator for the Yii framework 2.0

259709.1k31](/packages/yiisoft-yii2-apidoc)[arogachev/yii2-sortable

Sortable ActiveRecord for Yii 2 framework

1637.8k4](/packages/arogachev-yii2-sortable)[mdmsoft/yii2-ar-behaviors

Behaviors for Yii2

1825.0k1](/packages/mdmsoft-yii2-ar-behaviors)

PHPackages © 2026

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