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

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

graychen/yii2-basic-auth
========================

basic auth for yii

v0.0.2(7y ago)11.4k1MITPHP

Since Jun 11Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (3)Used By (0)

yii2-basic-auth [![Latest Stable Version](https://camo.githubusercontent.com/4b6520b9ccbfefdd7b4e850ef51cff55923af18b7129817ddc6184ec1e15160b/68747470733a2f2f706f7365722e707567782e6f72672f677261796368656e2f796969322d62617369632d617574682f76657273696f6e)](https://packagist.org/packages/graychen/yii2-basic-auth)
=======================================================================================================================================================================================================================================================================================================================

[](#yii2-basic-auth-)

[![Total Downloads](https://camo.githubusercontent.com/5e3504c0d6d1eae6d88bb51123248205fb5e56096dfcce1f9a996f53711aa63d/68747470733a2f2f706f7365722e707567782e6f72672f677261796368656e2f796969322d62617369632d617574682f646f776e6c6f616473)](https://packagist.org/packages/graychen/yii2-basic-auth)[![Build Status](https://camo.githubusercontent.com/b21b9c3552c1aa0c2d9a405d31566e99682bb7bb8c9cd5283034182384a2d13b/68747470733a2f2f7472617669732d63692e6f72672f477261796368656e2f796969322d62617369632d617574682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Graychen/yii2-basic-auth)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ffd0c994ae9e167700da7f4bdfb912a1f61e8de88531489af1bbaa7cd76a6a8d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f477261796368656e2f796969322d62617369632d617574682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Graychen/yii2-basic-auth/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/d9218f58ed68bce653cade4e613f7d12e4b6a4c30297b7c0bb28ad1166904797/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f477261796368656e2f796969322d62617369632d617574682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Graychen/yii2-basic-auth/?branch=master)[![Build Status](https://camo.githubusercontent.com/54f2f2233a9eee35f2464dc305f951e5525771b1ab6adfe4318d623e45f44718/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f477261796368656e2f796969322d62617369632d617574682f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Graychen/yii2-basic-auth/build-status/master)[![StyleCI](https://camo.githubusercontent.com/795948db0c197aba6ad33a5763f1da10a80c0d230f0eaac1220458df1008bb0a/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130393039373230372f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/109097207)

This is a basic module for app registration. It registers applications through the background and verifies the API in the way of basic authentication (这是一个app注册的基本模块，通过后台注册应用，以基本认证的方式对api进行验证)

Usage
-----

[](#usage)

### Config Migration

[](#config-migration)

```
'controllerMap' => [
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationPath' => [
            '@graychen/yii2/basic/auth/migrations'
        ],
    ],
],
```

Run Migration
-------------

[](#run-migration)

```
$ yii migrate/up
```

Config backend module in components part
----------------------------------------

[](#config-backend-module-in-components-part)

```
'auth' => [
    'class' => 'graychen\yii2\basic\auth\Module',
]
```

after that,you can website `https://localhost/admin/app`

Add behaviors in your Controller
--------------------------------

[](#add-behaviors-in-your-controller)

```
use graychen\yii2\basic\auth\models\App;
use graychen\yii2\basic\auth\filters\HttpBasicAuth;

    public function behaviors()
    {
        return [
            'authenticator' => [
                'class' => HttpBasicAuth::className(),
                'auth' => function ($username, $password) {
                    return App::findOne([
                        'app_key' => $username,
                        'app_secret' => $password,
                    ]);
                }
            ]
        ];
    }
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~10 days

Total

2

Last Release

2885d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4189971?v=4)[Graychen](/maintainers/Graychen)[@Graychen](https://github.com/Graychen)

---

Top Contributors

[![Graychen](https://avatars.githubusercontent.com/u/4189971?v=4)](https://github.com/Graychen "Graychen (9 commits)")[![zacksleo](https://avatars.githubusercontent.com/u/3369169?v=4)](https://github.com/zacksleo "zacksleo (9 commits)")

---

Tags

yii2-extensionyii2-modules

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graychen-yii2-basic-auth/health.svg)

```
[![Health](https://phpackages.com/badges/graychen-yii2-basic-auth/health.svg)](https://phpackages.com/packages/graychen-yii2-basic-auth)
```

###  Alternatives

[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5682.0M15](/packages/directorytree-ldaprecord-laravel)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)

PHPackages © 2026

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