PHPackages                             devmary/yii2-auth - 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. devmary/yii2-auth

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

devmary/yii2-auth
=================

Two-Factor Authentication

0101PHP

Since Feb 22Pushed 8y ago1 watchersCompare

[ Source](https://github.com/devmary/yii2-auth)[ Packagist](https://packagist.org/packages/devmary/yii2-auth)[ RSS](/packages/devmary-yii2-auth/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Two-Factor Authentication
=========================

[](#two-factor-authentication)

Two-Factor Authentication

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

[](#installation)

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

Either run

```
composer require devmary/yii2-auth:@dev

```

or add

```
"devmary/yii2-auth": "*"

```

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

Configure
---------

[](#configure)

Add following lines to your main configuration file:

```
'modules' => [
    'auth' => [
        'class' => 'devmary\auth\Module',
    ],
],
```

Update database schema
----------------------

[](#update-database-schema)

The last thing you need to do is updating your database schema by applying the migrations. Make sure that you have properly configured `db` application component and run the following command:

```
$ php yii migrate/up --migrationPath=@vendor/devmary/yii2-auth/migrations
```

Usage
-----

[](#usage)

Once the extension is installed, add action to your login form:

```
$form = ActiveForm::begin([
    ...
    'action' => ['auth/login/ajax-login'],
    ...
]);
```

and use following code in your login view file:

```
