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

AbandonedArchivedLibrary[Framework](/categories/framework)

nordsoftware/yii2-account
=========================

Account module for the Yii framework.

2.0.0(10y ago)261.8k—0%12BSD-3-ClausePHPPHP &gt;=5.5.0

Since Jul 27Pushed 10y ago14 watchersCompare

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

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

yii2-account
============

[](#yii2-account)

[![Build Status](https://camo.githubusercontent.com/a0ad8edb5bbb2ba5559d005020aec5f5d4d6daf76b40ebb1dd7c18b0f2b1c554/68747470733a2f2f7472617669732d63692e6f72672f6e6f7264736f6674776172652f796969322d6163636f756e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nordsoftware/yii2-account)[![Code Climate](https://camo.githubusercontent.com/fee6fafb953f73b595da85b67552011b1802de241f89ab94a45dd3157b87f4fb/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6e6f7264736f6674776172652f796969322d6163636f756e742f6261646765732f6770612e737667)](https://codeclimate.com/github/nordsoftware/yii2-account)[![Latest Stable Version](https://camo.githubusercontent.com/236b11ee9d52afccf2702929c2a0e5cd848e1e20b7e354884226ea70f74dc894/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7264736f6674776172652f796969322d6163636f756e742f762f737461626c652e737667)](https://packagist.org/packages/nordsoftware/yii2-account) [![Total Downloads](https://camo.githubusercontent.com/662eca74cc24b6172549c3543df5b9f4ff1e67a9e30e115c0dc0a40619bb7626/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7264736f6674776172652f796969322d6163636f756e742f646f776e6c6f6164732e737667)](https://packagist.org/packages/nordsoftware/yii2-account) [![Latest Unstable Version](https://camo.githubusercontent.com/ee828bc04ac76566ebeb88184070553459ba9823c3ac0977176a2d2a03343cf0/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7264736f6674776172652f796969322d6163636f756e742f762f756e737461626c652e737667)](https://packagist.org/packages/nordsoftware/yii2-account) [![License](https://camo.githubusercontent.com/773a4f27d60b9747c3b46121a09709fc13f55ddd4bea10ba610922cd4ccc2494/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7264736f6674776172652f796969322d6163636f756e742f6c6963656e73652e737667)](https://packagist.org/packages/nordsoftware/yii2-account)

A module for the Yii framework that provides common account functionality.

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

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

This project was inspired by both the [http://github.com/mishamx/yii-user](yii-user)and [https://github.com/dektrium/yii2-user](yii2-user) modules and was carefully developed with our expertise in Yii following the best practices of the framework. The module uses Yii's own password methods in `yii\base\Security`, alternatively you can implement our `PasswordHasherInterface` to hash passwords differently. Other features include interfaces for sending mail and creating authentication tokens; various password security features and much more. For more details refer to the features section below.

Features
--------

[](#features)

- Secure accounts (bcrypt encryption) **DONE**
- Optional sign-up process (enabled by default) **DONE**
- Captcha support on sign up **DONE**
- Optional account activation (enabled by default) **DONE**
- Log in / Log out **DONE**
- Sign up and log in through third-party services **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**

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist nordsoftware/yii2-account "*"

```

or add

```
"nordsoftware/yii2-account": "*"

```

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

Before you can start using the module you need to apply its database migrations. To do so run the following command:

```
yii migrate --migrationPath="vendor/nordsoftware/yii2-account/src/migrations"

```

Usage
-----

[](#usage)

Once the extension is installed, simply modify your application configuration as follows:

```
return [
    'bootstrap' => [
        'nord\yii\account\Bootstrap'
        // ...
    ],
    'modules' => [
        'account' => 'nord\yii\account\Module',
        // ...
    ],
    // ...
];
```

### Configuration

[](#configuration)

The following configurations are available for the `nord\yii\account\Module` class:

- **classMap** *array* map over classes to use within the module.
- **enableActivation** *bool* whether to enable account activation (defaults to `true`).
- **enableSignup** *bool* whether to enable the sign-up process (defaults to `true`).
- **enableCaptcha** *bool* whether to enable CAPTCHA when signing up (defaults to `false`).
- **enableClientAuth** *bool* whether to enable client authentication (defaults to `false`).
- **userConfig** *array* configuration passed to `yii\web\User`.
- **passwordConfig** *array* configuration passed to `PasswordStrengthValidator`.
- **captchaConfig** *array* configuration passed to `CaptchaAction`.
- **clientAuthConfig** *array* configuration passed to `yii\authclient\Collection`.
- **urlConfig** *array* configuration for the URLs used by the module.
- **usernameAttribute** *string* name of the username attribute (defaults to `username`).
- **emailAttribute** *string* name of the email attribute (defaults to `email`).
- **passwordAttribute** *string* name of the password attribute (defaults to `password`).
- **messageSource** *string* message source component to use for the module.
- **messagePath** *string* message path to use for the module.

### Parameters

[](#parameters)

The following parameters are available for the `nord\yii\account\Module` class:

- **fromEmailAddress** *string* from e-mail address used when sending e-mail.
- **numAllowedFailedLoginAttempts** *int* number of failed login attempts before the account is locked (defaults to 10)
- **minUsernameLength** *int* minimum length for usernames (defaults to 4).
- **minPasswordLength** *int* minimum length for passwords (defaults to 6).
- **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).
- **tokenExpireTime** *int* number of seconds for the authorization tokens to expire (defaults to 1 hour).

Usage
-----

[](#usage-1)

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

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

```

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

```
yii account/create demo demo1234
```

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
- **authKey** *varchar(255) not null* authentication key used for cookie authentication
- **email** *varchar(255) not null* account email
- **lastLoginAt** *datetime null default null* when the user last logged in
- **createdAt** *datetime null default null* when the account was created
- **status** *int(11) default '0'* account status (e.g. unactivated, 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' => [
    'class' => 'nord\yii\account\Module',
    'classMap' => [
        'account' => 'MyAccount',
    ],
],
```

### Custom models

[](#custom-models)

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\\Account* account model
- **token** *models\\AccountToken* account token model
- **provider** *models\\AccountProvider* account provider model
- **loginHistory** *models\\AccountLoginHistory* login history model
- **passwordHistory** *models\\AccountPasswordHistory* password history model
- **loginForm** *models\\LoginForm* login form
- **passwordForm** *models\\PasswordForm* base form that handles passwords
- **signupForm** *models\\SignupForm* signup form
- **connectForm** *models\\ConnectForm* connect form
- **forgotPassword** *models\\ForgotPasswordForm* forgot password form
- **passwordBehavior** *behaviors/PasswordAttributeBehavior* password attribute behavior
- **passwordValidator** *validators/PasswordStrengthValidator* password strength validator
- **webUser** *yii\\web\\User* web user component
- **captcha** *yii\\captcha\\Captcha* captcha widget
- **captchaAction** *yii\\captcha\\CaptchaAction* captcha action

### Custom controllers

[](#custom-controllers)

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

```
'account' => [
    'class' => 'nord\yii\account\Module',
    'controllerMap' => [
        'authenticate' => 'MyAuthenticateController',
    ],
],
```

Custom components
-----------------

[](#custom-components)

If you want to change the components used by the module, here is a complete list of the available interfaces:

- **dataContract** *components\\datacontract\\DataContractInterface* abstraction layer between the module and its data model (defaults to `DataContract`)
- **mailSender** *components\\mailsender\\MailSenderInterface* component used for sending e-mail (defaults to `YiiMailSender`)
- **passwordHasher** *components\\passwordhasher\\PasswordHasherInterface* component used for hashing password (defaults to `YiiPasswordHasher`)
- **tokenGenerator** *components\\tokengenerator\\TokenGeneratorInterface* component used for generating random tokens (default to `YiiTokenGenerator`)

You might want to look at the bundled implementations before making your own because we already support e.g. sending mail through Mandrill.

Contribute
----------

[](#contribute)

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

### Running tests

[](#running-tests)

Coming soon ...

### Translate

[](#translate)

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

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 98.7% 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 ~133 days

Total

3

Last Release

3676d ago

Major Versions

1.0.1 → 2.0.02016-04-18

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.5.0

### Community

Maintainers

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

---

Top Contributors

[![cniska](https://avatars.githubusercontent.com/u/1044868?v=4)](https://github.com/cniska "cniska (78 commits)")[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (1 commits)")

---

Tags

yii-extension

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/nordsoftware-yii2-account/health.svg)

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

###  Alternatives

[yii2-starter-kit/yii2-starter-kit

Yii2 Starter Kit Application Template

1.4k6.6k](/packages/yii2-starter-kit-yii2-starter-kit)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)

PHPackages © 2026

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