PHPackages                             yzh52521/think-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. yzh52521/think-auth

ActiveThink-extend

yzh52521/think-auth
===================

The Auth Library For ThinkPHP6

v3.0.8(3y ago)260[1 issues](https://github.com/yzh52521/think-auth/issues)Apache-2.0PHPPHP &gt;=8.0.2

Since May 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yzh52521/think-auth)[ Packagist](https://packagist.org/packages/yzh52521/think-auth)[ RSS](/packages/yzh52521-think-auth/feed)WikiDiscussions v3 Synced today

READMEChangelog (9)Dependencies (3)Versions (12)Used By (0)

ThinkPHP6+ 权限认证
===============

[](#thinkphp6-权限认证)

安装
--

[](#安装)

```
composer require yzh52521/think-auth

```

基础user表

```
CREATE TABLE `user` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '用户名称',
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '邮箱地址',
`email_verified_at` timestamp NULL DEFAULT NULL COMMENT '邮箱验证时间',
`phone` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '手机号',
`phone_verified_at` timestamp NULL DEFAULT NULL COMMENT '手机验证时间',
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '密码',
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '记住密码token',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_email_unique` (`email`),
UNIQUE KEY `user_phone_unique` (`phone`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
```

Auth常用方法

```
//通过账号密码登录  第二个参数 此值指示是否需要验证会话的 「记住我」 功能
Auth::attempt(['username' => 'tp5er@qq.com', 'password' => '123456'], $remember = true);
//通过用户实例登录
Auth::login(User::find(1), $remember = false);
//只验证一次
Auth::once(['username' => 'tp5er@qq.com', 'password' => '123456'])

//通过id登录
Auth::loginUsingId(1,$remember = false)
在没有会话或cookie的情况下，将给定的用户ID登录认证用户
Auth::onceUsingId(1);

// 获取当前的认证用户信息 ...
$user = Auth::user();
// 获取当前的认证用户id ...
$id = Auth::id();
if (Auth::check()) {
    // 用户已登录...
}
//使用户退出登录（清除会话）
Auth::logout();

//访问特定的看守器实例
Auth::guard('api')->attempt($credentials,$remember = false);
Auth::guard('api')->login(User::find(1), $remember = false);

```

###  Health Score

26

—

LowBetter than 46% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Recently: every ~1 days

Total

11

Last Release

1109d ago

Major Versions

v2.x-dev → v3.0.02022-09-21

PHP version history (2 changes)v2.x-devPHP &gt;=7.1.0

v3.0.0PHP &gt;=8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/052aa4acd90ad5d672ae5abe8d27d1f576f9c07e1967e2f6bced03b84079310f?d=identicon)[yuanzhihai](/maintainers/yuanzhihai)

---

Top Contributors

[![yuanzhihai](https://avatars.githubusercontent.com/u/15060466?v=4)](https://github.com/yuanzhihai "yuanzhihai (36 commits)")

### Embed Badge

![Health badge](/badges/yzh52521-think-auth/health.svg)

```
[![Health](https://phpackages.com/badges/yzh52521-think-auth/health.svg)](https://phpackages.com/packages/yzh52521-think-auth)
```

###  Alternatives

[topthink/think

the new thinkphp framework

8.0k1.2M12](/packages/topthink-think)[topthink/think-queue

The ThinkPHP6 Queue Package

641664.0k66](/packages/topthink-think-queue)[topthink/think-swoole

Swoole extend for thinkphp

504170.5k18](/packages/topthink-think-swoole)[topthink/think-captcha

captcha package for thinkphp

132925.4k61](/packages/topthink-think-captcha)[topthink/think-worker

workerman extend for thinkphp

202224.6k9](/packages/topthink-think-worker)[topthink/think-migration

96452.1k117](/packages/topthink-think-migration)

PHPackages © 2026

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