PHPackages                             mztest/yii2-ucenter-module - 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. mztest/yii2-ucenter-module

ActiveLibrary

mztest/yii2-ucenter-module
==========================

Yii2 module for integration ucenter.

1.0.1(8y ago)056MITPHP

Since Sep 15Pushed 8y agoCompare

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

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

yii2-ucenter-module
===================

[](#yii2-ucenter-module)

Yii2 module for integration ucenter

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist mztest/yii2-ucenter-module "*"

```

or add

```
"mztest/yii2-ucenter-module": "*"

```

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

Usage
-----

[](#usage)

Step 1:

Login UCenter admin system, create a new application.

```
应用的主 URL: http://your site doamin/ucenter

```

Step 2:

Save the config into `@app/config/ucenter.php`

```
define('UC_CONNECT', 'mysql');
define('UC_DBHOST', 'localhost');
define('UC_DBUSER', '');
define('UC_DBPW', '');
define('UC_DBNAME', '');
define('UC_DBCHARSET', 'utf8');
define('UC_DBTABLEPRE', '`ultrax`.pre_ucenter_');
define('UC_DBCONNECT', '0');
define('UC_KEY', '');
define('UC_API', 'http://youdomain/discuz/uc_server');
define('UC_CHARSET', 'utf-8');
define('UC_IP', '');
define('UC_APPID', '2');
define('UC_PPP', '20');

// For auto creating discuz member
define('UC_DISCUZ_MEMBER', true);
define('UC_DISCUZTABLEPRE', '`ultrax`.pre_');
```

Step 3:

Config `@app/config/main.php`

```
return [
    '...',
    'modules' => [
        'ucenter' => [
            'class' => 'mztest\ucenter\Module',
            'configFile' => '@app/config/ucenter.php' // default '@app/config/ucenter.php',
            'userModel' => '\app\models\User',
            'emailAttribute' => 'email',
        ],
    ],
    'components' => [
        '...',
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                ['pattern' => 'ucenter/api/uc.php', 'route' => 'ucenter/api/index'],
            ],
        ],
    ],
    '...'
];
```

Step 4:

About method, using `camelCase()`. Please see [PSR-1#methods](http://www.php-fig.org/psr/psr-1/#43-methods).

```
uc_user_register() to ucUserRegister()
uc_get_user() to ucGetUser()
```

Enjoy it.

Example
-------

[](#example)

Synlogin after user login.

Sometimes we build main site first, then merge it into ucenter later, so a little check was added here.

```
// synchronize register and login
try {
    $uCenterClient = Yii::$app->getModule('ucenter')->getUCenterClient();
    if ($uCenterUser = $uCenterClient->ucGetUser($model->email)) {
        list($uCenterUid,,) = $uCenterUser;
    } else {
        $uCenterUid = $uCenterClient->ucUserRegister($model->email, $model->password, $model->email);
        if ($uCenterUid < 0) {
            $uCenterUid = false;
        }
    }
    if ($uCenterUid && ($syncScript = $uCenterClient->ucUserSynlogin($uCenterUid))) {
        Yii::$app->session->setFlash('success', $syncScript);
    }
}  catch (\Exception $e) {
    //
}
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

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

Total

2

Last Release

3157d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a6467ec78dea5fcad4d67b5b3181bd5960294887e0a51819d35d27554bf0208?d=identicon)[mztest](/maintainers/mztest)

---

Top Contributors

[![mztest](https://avatars.githubusercontent.com/u/323810?v=4)](https://github.com/mztest "mztest (20 commits)")

### Embed Badge

![Health badge](/badges/mztest-yii2-ucenter-module/health.svg)

```
[![Health](https://phpackages.com/badges/mztest-yii2-ucenter-module/health.svg)](https://phpackages.com/packages/mztest-yii2-ucenter-module)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)

PHPackages © 2026

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