PHPackages                             leonis/apikey-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. leonis/apikey-auth

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

leonis/apikey-auth
==================

Laravel api key auth guard.

0.3(6y ago)11952MITPHP

Since Nov 6Pushed 6y agoCompare

[ Source](https://github.com/yangliulnn/apikey-auth)[ Packagist](https://packagist.org/packages/leonis/apikey-auth)[ RSS](/packages/leonis-apikey-auth/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

apikey-auth
===========

[](#apikey-auth)

API key Authentication for Laravel and Lumen.

安装
--

[](#安装)

```
composer require leonis/apikey-auth
```

配置
--

[](#配置)

### Laravel

[](#laravel)

1. 在 `config/app.php` 注册 ServiceProvider (Laravel 5.5 及以上无需手动注册)

    ```
    'providers' => [
        // ...
        Leonis\ApiKeyAuth\Providers\ServiceProvider::class
     ],
    ```
2. 创建配置文件：

    ```
    php artisan vendor:publish --provider="Leonis\ApiKeyAuth\ApiKeyAuthServiceProvider"
    ```
3. 运行数据库迁移

    ```
    php artisan migrate
    ```

### lumen

[](#lumen)

1. 在 `bootstrap/app.php` 注册 ServiceProvider

    ```
    $app->register(Leonis\ApiKeyAuth\Providers\ServiceProvider::class);
    ```
2. 复制配置和数据库迁移文件

    将 `vendor/leonis/apikey-auth/config/config.php` 拷贝到 `config` 目录下，并将文件名改成 `api_key.php`; 将 `vendor/leonis/apikey-auth/database/migrations` 目录中的文件拷贝到 `database/migrations` 目录下。
3. 运行数据库迁移

    ```
    php artisan migrate
    ```

使用
--

[](#使用)

1. 修改 `auth.php` 配置文件中的 `guards` :

    ```
    'guards' => [
            // ...

            'api' => [
                'driver' => 'api_key',
                'provider' => 'users',
            ],
        ],
    ```
2. 为用户生成 Api Key :

    ```
    ApiKey::fromUser(User::first());
    ApiKey::fromId($user->id);
    ```
3. 请求 API :

    TODO

License
-------

[](#license)

[MIT](https://opensource.org/licenses/MIT)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

3

Last Release

2524d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dfabc6444aca5c560a8812ae9a4db6df46cfe73de9f9cee975b73ee96060a256?d=identicon)[yangliulnn](/maintainers/yangliulnn)

### Embed Badge

![Health badge](/badges/leonis-apikey-auth/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[stechstudio/laravel-jwt

Helper package that makes it easy to generate, consume, and protect routes with JWT tokens in Laravel

126117.6k](/packages/stechstudio-laravel-jwt)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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