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 5d 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 37% 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

1128d 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

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)[overtrue/laravel-follow

User follow unfollow system for Laravel.

1.2k404.7k5](/packages/overtrue-laravel-follow)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5161.1M3](/packages/robsontenorio-laravel-keycloak-guard)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)

PHPackages © 2026

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