PHPackages                             cola/hector - 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. cola/hector

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

cola/hector
===========

laravel api guard base jwt

0.4.0(3y ago)164WTFPLPHPPHP ^7.4|^8.0

Since May 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/zedisdog/hector)[ Packagist](https://packagist.org/packages/cola/hector)[ RSS](/packages/cola-hector/feed)WikiDiscussions develop Synced 3w ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

hector
======

[](#hector)

laravel 的 api 认证中间件，基于jwt。

安装
--

[](#安装)

```
composer require cola/hector
```

用户模型中 use Cola\\Hector\\HasApiToken

使用
--

[](#使用)

### 路由中间件

[](#路由中间件)

```
Route::middleware('auth:hector')->xxxxx;
```

### 创建token

[](#创建token)

```
$account->createToken();
```

向token中添加自定义字段

```
$account->withPayloads(['role' => $account->roles()->first()->name])->createToken();
```

### 认证通过后可以获取token中的字段

[](#认证通过后可以获取token中的字段)

```
$account->payloads['role'];
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Recently: every ~159 days

Total

7

Last Release

1175d ago

### Community

Maintainers

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

---

Top Contributors

[![zedisdog](https://avatars.githubusercontent.com/u/8280666?v=4)](https://github.com/zedisdog "zedisdog (21 commits)")

### Embed Badge

![Health badge](/badges/cola-hector/health.svg)

```
[![Health](https://phpackages.com/badges/cola-hector/health.svg)](https://phpackages.com/packages/cola-hector)
```

###  Alternatives

[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[firefly-iii/data-importer

Firefly III Data Import Tool.

8015.8k](/packages/firefly-iii-data-importer)[rainlab/user-plugin

User plugin for October CMS

11955.0k15](/packages/rainlab-user-plugin)

PHPackages © 2026

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