PHPackages                             bupy7/yii2-password-behavior - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bupy7/yii2-password-behavior

AbandonedArchivedYii2-extension[Authentication &amp; Authorization](/categories/authentication)

bupy7/yii2-password-behavior
============================

Behavior for change and create password of user account.

1.0.1(10y ago)38.3kBSD-3-ClausePHP

Since Oct 10Pushed 10y ago1 watchersCompare

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

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

yii2-password-behavior
======================

[](#yii2-password-behavior)

Behavior for change and create password of user account.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist bupy7/yii2-password-behavior "*"

```

or add

```
"bupy7/yii2-password-behavior": "*"

```

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

Usage
-----

[](#usage)

**Implement your user identity model with `bupy7\password\PasswordInterface` and add following code:**

```
use Yii;

/**
 * @inheritdoc
 */
public function validatePassword($password)
{
    return Yii::$app->security->validatePassword($password, $this->password);
}

/**
 * @inheritdoc
 */
public function setPassword($password)
{
    $this->password = Yii::$app->security->generatePasswordHash($password);
}
```

**Added following properties to your model:**

```
public $old_password;
public $new_password;
public $confirmed_password;
```

**Attach behavior to model in your controller:**

```
use bupy7\password\PasswordBehavior;

$model->attachBehavior('passwordBehavior', [
    'class' => PasswordBehavior::className(),
    // other configurations
]);
```

### If you want set password with checking old password

[](#if-you-want-set-password-with-checking-old-password)

**In your controller:**

```
use bupy7\password\PasswordBehavior;

$model->attachBehavior('passwordBehavior', [
    'class' => PasswordBehavior::className(),
    'skipOnEmpty' => true,
    'checkPassword' => true,
    'scenarios' => [$model->scenario],
]);
```

### If you want set new password without checking old password

[](#if-you-want-set-new-password-without-checking-old-password)

**In your controller:**

```
use bupy7\password\PasswordBehavior;

$model->attachBehavior('passwordBehavior', [
    'class' => PasswordBehavior::className(),
    'skipOnEmpty' => true,
    'checkPassword' => false,
    'scenarios' => [$model->scenario],
]);
```

### If password must be set (example, registration)

[](#if-password-must-be-set-example-registration)

```
use bupy7\password\PasswordBehavior;

$model->attachBehavior('passwordBehavior', [
    'class' => PasswordBehavior::className(),
    'skipOnEmpty' => false,
    'checkPassword' => false,
    'scenarios' => [$model->scenario],
]);
```

\##License

yii2-password-behavior is released under the BSD 3-Clause License.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

3864d ago

### Community

Maintainers

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

---

Top Contributors

[![bupy7](https://avatars.githubusercontent.com/u/5145037?v=4)](https://github.com/bupy7 "bupy7 (10 commits)")

---

Tags

passwordyii2extensionBehavior

### Embed Badge

![Health badge](/badges/bupy7-yii2-password-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/bupy7-yii2-password-behavior/health.svg)](https://phpackages.com/packages/bupy7-yii2-password-behavior)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

791.2M17](/packages/kartik-v-yii2-password)[kakadu-dev/yii2-jwt-auth

Extension provide JWT auth for Yii2

105.8k](/packages/kakadu-dev-yii2-jwt-auth)

PHPackages © 2026

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