PHPackages                             yii-dream-team/yii2-lockable-activerecord - 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. [Database &amp; ORM](/categories/database)
4. /
5. yii-dream-team/yii2-lockable-activerecord

ActiveYii-extension[Database &amp; ORM](/categories/database)

yii-dream-team/yii2-lockable-activerecord
=========================================

Pessimistic locking behavior for Yii2 ActiveRecord

1.0.5(8y ago)1888.8k↑10.4%4MITPHPPHP &gt;=5.4.0

Since Mar 23Pushed 8y ago4 watchersCompare

[ Source](https://github.com/yii-dream-team/yii2-lockable-activerecord)[ Packagist](https://packagist.org/packages/yii-dream-team/yii2-lockable-activerecord)[ RSS](/packages/yii-dream-team-yii2-lockable-activerecord/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

Pessimistic locking behavior for Yii2 ActiveRecord
==================================================

[](#pessimistic-locking-behavior-for-yii2-activerecord)

This package allows you to use pessimistic locking (select for update) when you work with ActiveRecord models.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist yii-dream-team/yii2-lockable-activerecord "*"

```

or add

```
"yii-dream-team/yii2-lockable-activerecord": "*"

```

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

Usage
-----

[](#usage)

Attach the behavior to your controller class.

```
public function behaviors()
{
    return [
        '\yiidreamteam\behaviors\LockableActiveRecord',
    ];
}

```

Add @mixin phpdoc to you class definition.

```
/**
 * Class Sample
 * @package common\models
 *
 * @mixin \yiidreamteam\behaviors\LockableActiveRecord
 */
class Sample extends ActiveRecord { ... }

```

Use model locks in transaction.

```
$dbTransaction = $model->getDb()->beginTransaction(\yii\db\Transaction::SERIALIZABLE);
try {
    $model->lock();
    $model->doSomethingWhileLocked();
    $dbTransaction->commit();
} catch(\Exception $e) {
    $dbTransaction->rollBack();
    throw $e;
}

```

Licence
-------

[](#licence)

MIT

Links
-----

[](#links)

- [Official site](http://yiidreamteam.com/yii2/lockable-activerecord)
- [Composer package](https://packagist.org/packages/yii-dream-team/yii2-lockable-activerecord)
- [Locking in MySQL InnoDB](https://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html)
- [Locking in PostgreSQL](https://www.postgresql.org/docs/9.4/static/explicit-locking.html)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~172 days

Recently: every ~187 days

Total

6

Last Release

3257d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1297270?v=4)[Vahid G](/maintainers/lagman)[@lagman](https://github.com/lagman)

---

Top Contributors

[![metalagman](https://avatars.githubusercontent.com/u/1983796?v=4)](https://github.com/metalagman "metalagman (3 commits)")[![BioSin](https://avatars.githubusercontent.com/u/1442288?v=4)](https://github.com/BioSin "BioSin (1 commits)")

---

Tags

yii2Behavioractiverecordlock

### Embed Badge

![Health badge](/badges/yii-dream-team-yii2-lockable-activerecord/health.svg)

```
[![Health](https://phpackages.com/badges/yii-dream-team-yii2-lockable-activerecord/health.svg)](https://phpackages.com/packages/yii-dream-team-yii2-lockable-activerecord)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[voskobovich/yii2-linker-behavior

This behavior makes it easy to maintain many-to-many and one-to-many relations in your ActiveRecord models.

80336.2k9](/packages/voskobovich-yii2-linker-behavior)[nhkey/yii2-activerecord-history

Storage history of changes to ActiveRecord

46148.8k1](/packages/nhkey-yii2-activerecord-history)[spinitron/yii2-dynamic-ar

Extends Yii ActiveRecord for Maria Dynamic Columns

577.0k](/packages/spinitron-yii2-dynamic-ar)[nanson/yii2-postgis

Yii2-extension to work with postgis data

1953.6k](/packages/nanson-yii2-postgis)[jlorente/yii2-activerecord-inheritance

ActiveRecord Inheritance is an util to provide the Class Table Inheritance Pattern the to the Yii2 framework. It fakes inheritance between two ActiveRecord classes.

184.2k](/packages/jlorente-yii2-activerecord-inheritance)

PHPackages © 2026

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