PHPackages                             fangxu/donews-user - 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. fangxu/donews-user

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

fangxu/donews-user
==================

DoNews User

1.4.3(7y ago)2990MITPHP

Since Sep 28Pushed 7y agoCompare

[ Source](https://github.com/nfangxu/donews-user)[ Packagist](https://packagist.org/packages/fangxu/donews-user)[ RSS](/packages/fangxu-donews-user/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (1)Versions (15)Used By (0)

DoNews 检测用户登录通用package
======================

[](#donews-检测用户登录通用package)

> 未登录用户会抛出 `DoNewsUserException`

环境变量配置
------

[](#环境变量配置)

- Token加密密钥: `DONEWS_USER_TOKEN_KEY`, 默认: `1234567890123456`
- Token过期天数: `DONEWS_USER_TOKEN_EXPIRED_DAYS`, 默认: `7`

example
-------

[](#example)

```
# user must login
Route::get("UserNeedLogin", function (\Fangxu\Donews\Contracts\DoNewsLoginUser $user) {
    dd("ID: " . $user->id());
});

# user can not login
Route::get("UserMayNotLogin", function (\Fangxu\Donews\Contracts\DoNewsUser $user) {
    dd("ID: " . $user->id());
});
```

注意
--

[](#注意)

- 安装完之后, 如果无法正常发现包, 使用命令 `composer dumpautoload` 来自动发现
- `config/database.php` 下添加 `redis` 配置

```
...
"redis" => [
	'client' => 'predis',
	...
 	'donews-user' => [
            "host" => env("USER_TOKEN_REDIS_HOST", '127.0.0.1'),
            "password" => env("USER_TOKEN_REDIS_PASSWORD", null),
            "port" => env("USER_TOKEN_REDIS_PORT", 6379),
            "database" => env("USER_TOKEN_REDIS_DB", 0),
        ],
]

```

- 如果使用集群Redis, 则需要在 `config/database.php` 下添加以下 `redis` 配置

```
...
"redis" => [
	'client' => 'predis',
	...
	"options" => [
            "cluster" => "redis",
        ],
 	'donews-user' => [
            [
            	"host" => env("USER_TOKEN_REDIS_CLUSTER_01_HOST", '127.0.0.1'),
            	"port" => env("USER_TOKEN_REDIS_CLUSTER_01_PORT", 6379),
            ],
	    [
            	"host" => env("USER_TOKEN_REDIS_CLUSTER_02_HOST", '127.0.0.1'),
            	"port" => env("USER_TOKEN_REDIS_CLUSTER_02_PORT", 6379),
            ],
	    ...
        ],
]

```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity70

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

Recently: every ~45 days

Total

14

Last Release

2624d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48e745eaab94e5e8f347aadc5b74046bb174895188f0507b1d46c0fa6cee6555?d=identicon)[nfangxu](/maintainers/nfangxu)

---

Top Contributors

[![nfangxu](https://avatars.githubusercontent.com/u/33243730?v=4)](https://github.com/nfangxu "nfangxu (33 commits)")

---

Tags

composerlaraveldonews

### Embed Badge

![Health badge](/badges/fangxu-donews-user/health.svg)

```
[![Health](https://phpackages.com/badges/fangxu-donews-user/health.svg)](https://phpackages.com/packages/fangxu-donews-user)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[solidry/api-generator

PHP-code generator (based on OAS) for Laravel framework, with complete support of JSON-API data format

32626.4k](/packages/solidry-api-generator)[ingria/laravel-x509-auth

Laravel 5 Client Certificate auth middleware

375.6k](/packages/ingria-laravel-x509-auth)

PHPackages © 2026

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