Centralized user database


I have multiple yii2 applications . I want to use common user table for all my yii2 applications. Iam using dektrium yii2-user extension in all my applications . Can you please suggest me some work around for this ?

add another database component to your yii app configure it to connect to user database and tell active record to use that connection

'components' => [

        'userDb' => [

            'class' => 'yii\db\Connection',

            'dsn' => 'mysql:host=localhost;dbname=testdb',

            'username' => 'demo',

            'password' => 'demo',



class User extends ActiveRecord


    // ...

    public static function getDb()


        // use the "db2" application component

        return \Yii::$app->userDb;  



Thank you alrazi :)