PHPackages                             azamath/yii-account - 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. azamath/yii-account

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

azamath/yii-account
===================

Extension that provides basic account functionality for the Yii PHP framework. Copy of nordsoftware/yii-account

1.2.1(11y ago)08BSD-3-ClausePHP

Since Jun 5Pushed 11y ago1 watchersCompare

[ Source](https://github.com/azamath/yii-account)[ Packagist](https://packagist.org/packages/azamath/yii-account)[ RSS](/packages/azamath-yii-account/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (7)Versions (12)Used By (0)

yii-account
===========

[](#yii-account)

[![Latest Stable Version](https://camo.githubusercontent.com/3d3948b8c553ae53bccf6618b65111b1d9b17e95af5d95434f3cde58ae42a5be/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7264736f6674776172652f7969692d6163636f756e742f76657273696f6e2e737667)](https://packagist.org/packages/nordsoftware/yii-account)[![Build Status](https://camo.githubusercontent.com/bb063d66087b6030399839683d5053bf2932180a85dae987b2dd064904e59671/68747470733a2f2f7472617669732d63692e6f72672f6e6f7264736f6674776172652f7969692d6163636f756e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nordsoftware/yii-account)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/945534070ff4a75d6d5d8689a99a4fceca2c5abe24368a588315bddf0443734d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e6f7264736f6674776172652f7969692d6163636f756e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nordsoftware/yii-account/?branch=master)

Extension that provides basic account functionality for the Yii PHP framework.

Why do I want this
------------------

[](#why-do-i-want-this)

This project was inspired by the \[[http://github.com/mishamx/yii-user\](yii-user](http://github.com/mishamx/yii-user](yii-user) module) and was carefully developed with our expertise in Yii following the best practices of the framework. It is more secure because it uses passwords with salt that are encrypted using bcrypt instead of password hashes. It also comes with support for sending mail with truly random authentication tokens that expire.

We are also currently working on additional security features (listed in the requirements below).

User interface
--------------

[](#user-interface)

[![Login](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/login.png)](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/login.png)
[![Signup](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/signup.png)](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/signup.png)
[![Forgot password](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/forgot-password.png)](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/forgot-password.png)
[![Change password](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/change-password.png)](https://raw.githubusercontent.com/nordsoftware/yii-account/develop/screenshots/change-password.png)

Requirements
------------

[](#requirements)

- Secure accounts (password + salt) **DONE**
- Sign up **DONE**
- Account activation (enabled by default) **DONE**
- Log in / Log out **DONE**
- Reset password **DONE**
- Email sending (with token validation) **DONE**
- Require new password every x days (disabled by default) **DONE**
- Password history (encrypted) to prevent from using same password twice **DONE**
- Lock accounts after x failed login attempts (disabled by default) **DONE**\_
- Console command for creating accounts **DONE**
- Proper README **WIP**

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

[](#installation)

The easiest way to install this extension is to use Composer.

Run the following command to download the extension:

```
php composer.phar require nordsoftware/yii-account:*
```

Add the following to your application configuration:

```
'modules' => array(
    'account' => array(
        'class' => '\nordsoftware\yii_account\Module',
    ),
),
'components' => array(
    'user' => array(
        'class' => '\nordsoftware\yii_account\components\WebUser',
    ),
),
```

To use the console command you need to add the following to your console application configuration:

```
'commandMap' => array(
    'account' => array(
        'class' => '\nordsoftware\yii_account\commands\AccountCommand',
    ),
),
```

Run the following command to apply database migrations (you need to have a database configured for your application):

```
php yiic.php migrate --migrationPath=account.migrations
```

### Without Composer

[](#without-composer)

If you are not using Composer, then you need to download the dependencies manually and add the following to your application configuration:

```
'aliases' => array(
    '\nordsoftware\yii_account' => __DIR__ . '/relative/path/to/yii-account/src',
    '\YiiPassword' => __DIR__ . '/relative/path/to/yiipassword/src',
    '\RandomLib' => __DIR__ . '/relative/path/to/randomlib/lib',
    '\SecureLib' => __DIR__ . '/relative/path/to/securelib/lib',
),
```

### Dependencies

[](#dependencies)

- Yiistrap
- YiiPassword
- RandomLib
- SecurityLib

### Configuration

[](#configuration)

The following configurations are available for the `\nordsoftware\yii_account\Module` class:

- **classMap** *array* map over classes to use within the module.
- **enableActivation** *bool* whether to enable account activation (defaults to true).
- **numAllowedFailedLogins** *int* number of a user can fail to login before the account is locked (defaults to 10)
- **loginExpireTime** *int* number of seconds for login cookie to expire (defaults to 30 days).
- **activateExpireTime** *int* number of seconds for account activation to expire (defaults to 30 days).
- **resetPasswordExpireTime** *int* number of seconds for password reset to expire (defaults to 1 day).
- **passwordExpireTime** *int* number of seconds for passwords to expire (defaults to disabled).
- **lockoutExpireTime** *int* number of seconds for account lockout to expire (defaults to 10 minutes).
- **fromEmailAddress** *string* from e-mail address used when sending mail.
- **messageSource** *string* message source component to use for the module.
- **registerStyles** *bool* whether to register the default styles.
- **defaultLayout** *string* path alias for the layout to use within the module.

Usage
-----

[](#usage)

Now you should be able to see the login page when you go to the following url:

```
index.php?r=account
```

You can run the following command to generate an account from the command line:

```
php yiic.php account create --username=demo --password=demo
```

Extending
---------

[](#extending)

This project was developed with a focus on re-usability, so before you start copy-pasting take a moment of your time and read through this section to learn how to extend this module properly.

### Custom account model

[](#custom-account-model)

You can use your own account model as long as you add the following fields to it:

- **username** *varchar(255) not null* account username
- **password** *varchar(255) not null* account password
- **email** *varchar(255) not null* account email
- **passwordStrategy** *varchar(255) not null* password encryption type
- **requireNewPassword** *tinyint(1) not null default '0'* whether account password must be changed
- **createdAt** *timestamp null default current\_timestamp* when the account was created
- **lastActiveAt** *timestamp null default null* when the account was last active
- **status** *int(11) default '0'* account status (e.g. inactive, activated)

Changing the model used by the extension is easy, simply configure it to use your class instead by adding it to the class map for the module:

```
'account' => array(
    'class' => '\nordsoftware\yii_account\Module',
    'classMap' => array(
        'account' => 'MyAccount', // defaults to \nordsoftware\yii_account\models\ar\Account
    ),
),
```

### Custom models, components or forms classes

[](#custom-models-components-or-forms-classes)

You can use the class map to configure any classes used by the module, here is a complete list of the available classes:

- **account** *models\\ar\\Account* account model
- **token** *models\\ar\\AccountToken* account token mode
- **loginHistory** *models\\ar\\AccountLoginHistory* login history model
- **passwordHistory** *models\\ar\\AccountPasswordHistory* password history model
- **userIdentity** *components\\UserIdentity* user identity
- **loginForm** *models\\form\\LoginForm* login form
- **passwordForm** *models\\form\\PasswordForm* base form that handles passwords
- **signupForm** *models\\form\\SignupForm* signup form (extends passwordForm)
- **forgotPassword** *models\\form\\ForgotPasswordForm* forgot password form

### Custom controllers

[](#custom-controllers)

If you want to use your own controllers you can map them using the module's controller map:

```
array(
    'account' => array(
        'class' => '\nordsoftware\yii_account\Module',
        'controllerMap' => array(
            'authorize' => 'AuthorizeController', // defaults to \nordsoftware\yii_account\controllers\AuthorizeController
        ),
    ),
),
```

### Custom views

[](#custom-views)

If you want to use your own views with this module you can override the views with your own by placing them either under your application under `protected\views\account` or your theme under `themes\views\account`.

### Extending the module itself

[](#extending-the-module-itself)

You may also want to extend the module itself, e.g. in order to implement proper email sending. In that case you can extend the module and override the methods necessary and configure your account to use your module instead:

```
'account' => array(
    'class' => 'MyAccountModule',
),
```

Normally you would need to copy all the views under your module, but we have made it easy so that you can only override the views you need to and the module will automatically look for the default views under the parent module.

The source code is also quite well documented so the easiest way to find out how to extend properly is to dive into the code and get to know the logic behind the functionality. Also, if you have any ideas for improvements feel free to file an issue or create a pull-request.

Contribute
----------

[](#contribute)

If you wish to contribute to this project feel free to create a pull-request to the `develop` branch.

### Run test suite

[](#run-test-suite)

To run the test suite you need to run the following commands:

```
export DB_HOST=
export DB_NAME=
export DB_USER=
export DB_PASS=
export BASE_URL=
erb tests/app/config/bootstrap.php.erb > tests/app/config/bootstrap.php
erb codeception.yml.erb > codeception.yml
erb tests/acceptance.suite.yml.erb > tests/acceptance.suite.yml
```

Now you can use the following command to run the test suite:

```
vendor/bin/codecept run
```

### Translate

[](#translate)

If you wish to translate this project you can find the translation templates under `src/messages/templates`. When you are done with your translation create a pull-request to the `develop` branch.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

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

10

Last Release

4354d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4448824?v=4)[Azamat Holmeer](/maintainers/azamath)[@azamath](https://github.com/azamath)

---

Top Contributors

[![cniska](https://avatars.githubusercontent.com/u/1044868?v=4)](https://github.com/cniska "cniska (32 commits)")[![azamath](https://avatars.githubusercontent.com/u/4448824?v=4)](https://github.com/azamath "azamath (2 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/azamath-yii-account/health.svg)

```
[![Health](https://phpackages.com/badges/azamath-yii-account/health.svg)](https://phpackages.com/packages/azamath-yii-account)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[dflydev/hawk

Hawk

672.0M12](/packages/dflydev-hawk)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[crisu83/yii-auth

Web UI for the authorization manager of Yii PHP framework.

13439.8k](/packages/crisu83-yii-auth)

PHPackages © 2026

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