PHPackages                             qklin/laravel-auto-router - 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. [Framework](/categories/framework)
4. /
5. qklin/laravel-auto-router

ActiveLibrary[Framework](/categories/framework)

qklin/laravel-auto-router
=========================

laravel/lumen 注解自动路由

1.0.5(6y ago)027MITPHPPHP ^7.0CI failing

Since Nov 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/qklandy/laravel-autorouter)[ Packagist](https://packagist.org/packages/qklin/laravel-auto-router)[ RSS](/packages/qklin-laravel-auto-router/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Laravel/Lumen AutoRouter
========================

[](#laravellumen-autorouter)

Laravel/Lumen 注解路由自动加载和中间件自动注入

Table of Contents
-----------------

[](#table-of-contents)

1. [How](#how)
2. [Usage](#Usage)

### How

[](#how)

#### Install with Composer:

[](#install-with-composer)

```
composer require qklin/laravel-auto-router

```

#### Use simply:

[](#use-simply)

```
# add autorouter middleware
$app->routeMiddleware([
    //...

    'api_throttle' => \Qikl\AutoRouter\Middleware\ApiThrottleMiddleware::class,
    'token'        => \Qikl\AutoRouter\Middleware\TokenMiddleware::class,
    'check_sign'   => \Qikl\AutoRouter\Middleware\CheckSignMiddleware::class,
    'validate'     => \Qikl\AutoRouter\Middleware\ValidateMiddleware::class,
    'inside'       => \Qikl\AutoRouter\Middleware\InsideMiddleware::class,
]);

# add provider
$app->register(Qklin\AutoRouter\AppServiceProvider::class);

```

### Usage

[](#usage)

#### 目前支持的注解

[](#目前支持的注解)

1. arRouter: 可直接配置方法携带后缀控制中间件
2. arMethod: POST|GET|PUT|...
3. arOnlyInisde: 路由必须inside开头

#### 路由自动注入使用

[](#路由自动注入使用)

1. api必须【bapi】前缀。like：HotKeys =&gt; hot\_keys
2. 路径包含驼峰目录以【\_】分隔。like：HotKeys =&gt; hot\_keys
3. 方法包含【.】的目录以【\_】分隔。like：V1.0 =&gt; v1\_0
4. 方法包含驼峰以【-】分隔。like：getListsO =&gt; get-list-o

#### 控制器方法添加注解配置案例

[](#控制器方法添加注解配置案例)

```
具体案例, 模块根目录和控制器文件：app/Modules/Module/Hotkeys/V1.0/Controllers/IndexController.php
方法：getList，注解wptRouter getListO
路由：/m/module/hot-keys/v1_0/index/get-list-o

/**
 * 案例一 纯路由注解
 * 匹配：/m/module/articles/college/detail
 * @wptRouter
 * @return string
 */
public function detail()
{
}

/**
 * 案例二：路由注解并配置路由地址方法
 * 匹配：/m/module/articles/college/detail-o
 * @wptRouter detailO
 * @return string
 */
public function detail()
{
}

/**
 * 案例三：路由注解请求方法和开启内网注解
 * 匹配，且前缀必须inside开头：/inside/module/articles/college/detail-o
 * 只支持post和get请求方法
 * @wptRouter detailO
 * @wptMehtod POST|GET
 * @wptOnlyInside
 * @return string
 */
public function detail()
{
}

```

#### wptRouter注解配置说明

[](#wptrouter注解配置说明)

1. O:Operate 操作 自动注入节流中间件
2. L:Look 查看 自动移除节流中间件\[如果存在\]
3. I:Inside 内网 自动注入内网中间件，且放置最前\[如果不存在\]，自动剔除token中间件
4. N:NotAuth 无需授权，公开api，自动移除token中间件\[如果存在\]
5. V:validate 请求验证，自动移除请求验证中间件\[如果不存在\]
6. X:checkSign 请求验签
7. 如果都不存在，默认根据route.php配置走

#### 配置route.conf

[](#配置routeconf)

```

// 文件位置：app/config/route.php
// 本文件可配置可不配置，根据需求配置
return [
    "middleware" => [  //中间件，目前只支持
        "controllers" => [ // 路由控制器路径 => 中间件
            "h/module/ctl/action" => ["token", "validate"],
        ],
        "actions"     => [ // 控制器方法 => 中间件
        ]
    ]
];

```

#### laravel版本在Application可以注入configure方法

[](#laravel版本在application可以注入configure方法)

```
/**
 * 加载配置文件
 * @param $name
 */
public function configure($name)
{
    if (isset($this->loadedConfigurations[$name])) {
        return;
    }

    $this->loadedConfigurations[$name] = true;

    $path = $this->getConfigurationPath($name);

    if ($path && is_file($path)) {
        $this->make('config')->set($name, require $path);
    }
}

/**
 * 获取配置路径
 * @param null $name
 * @return string
 */
public function getConfigurationPath($name = null)
{
    if (!$name) {
        $appConfigDir = $this->basePath('config') . '/';

        if (file_exists($appConfigDir)) {
            return $appConfigDir;
        } else if (file_exists($path = __DIR__ . '/../config/')) {
            return $path;
        }
    } else {
        $appConfigPath = $this->basePath('config') . '/' . $name . '.php';

        if (file_exists($appConfigPath)) {
            return $appConfigPath;
        } else if (file_exists($path = __DIR__ . '/../config/' . $name . '.php')) {
            return $path;
        }
    }
}

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity55

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

Total

4

Last Release

2330d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d1b6d38c5719128cca213701c15f840b1dddb2a091f7984dbf2aff1e209c8ac?d=identicon)[qklandy](/maintainers/qklandy)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/qklin-laravel-auto-router/health.svg)

```
[![Health](https://phpackages.com/badges/qklin-laravel-auto-router/health.svg)](https://phpackages.com/packages/qklin-laravel-auto-router)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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