PHPackages                             kingbes/attribute - 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. kingbes/attribute

ActiveLibrary

kingbes/attribute
=================

Webman plugin kingbes/attribute

1.0.0(2y ago)432MITPHPPHP &gt;8.0

Since Jan 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/KingBes/Attribute)[ Packagist](https://packagist.org/packages/kingbes/attribute)[ RSS](/packages/kingbes-attribute/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Attribute
=========

[](#attribute)

🚀 🔥 🌈 基于webman使用 KingBes/Attribute 包实现的注解路由，中间件，权限标识，视图标识等解决方案

PHP8的注解方案
=========

[](#php8的注解方案)

更新日志
----

[](#更新日志)

### v1.0.0

[](#v100)

1. 应用插件也可注解路由
2. 可给应用或应用插件命名

下面是config/plugin/kingbes/attribute/attribute.php 注解配置

```
return [
    // 应用映射
    "bind" => [
        // "app.admin" 是admin应用 ; "plugin.foo" 是foo应用插件 ; 单应用 "app"
        "index" => "app",
        "blog" => "plugin.kbBlog"
    ],
    // 默认应用 应用映射的key
    "default" => "blog",
    // 忽略的应用路由 例如: ["app.admin","plugin.foo"] 表示忽略admin应用和foo应用插件的路由注解
    "route_lose" => []
];
```

获取注解信息

```
use Kingbes\Attribute\Annotation; //引入

Annotation::data() // 获取全部注解信息
Annotation::data("app") // 获取主应用的注解信息
Annotation::data("plugin") // 获取应用插件的注解信息
```

安装
--

[](#安装)

```
composer require kingbes/attribute
```

使用，建议结合php8的命名参数使用
------------------

[](#使用建议结合php8的命名参数使用)

```
use Kingbes\Attribute\Annotation; //引入

#[Annotation(
    title: "首页的",
    add: ["classnew" => "class新增一个"]
)]
class IndexController
{
    #[Annotation(
        title: "首页",
        path: ["/index", "/", "/home"],
        request: ["get", "post"],
        auth: true,
        add: ["newfun" => "方法新增一个"]
    )]
    public function index(Request $request)
    {
        return json(Annotation::data());
    }
}
```

其中：return json(Annotation::data()); 得到结果

```
[
    {
        "title": "首页的", // 默认：无Controller后缀的短class名
        "class": "\\app\\controller\\IndexController", // class
        "auth": false, // 权限标识 默认： false
        "methods": [ // 方法数组
            {
                "title": "首页", // 默认：method名
                "path": [ // 路由路径组 默认：/无Controller后缀的短class名/method名  比如：/index/home
                    "/index",
                    "/",
                    "/home"
                ],
                "request": [ // 可请求方式 默认： ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
                    "get",
                    "post"
                ],
                "middleware": [], // 中间件
                "auth": true, // 权限标识
                "view": false, // 视图标识
                "name": "index.index", // 路由名 默认：无Controller后缀的短class名.method名  比如: index.index
                "method": "index", // method名
                "newfun": "方法新增一个" // 新增数据 默认：不存在
            }
        ],
        "classnew": "class新增一个" // 新增数据 默认：不存在
    }
]
```

class中仅title、add、auth有效

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

2

Last Release

854d ago

Major Versions

0.0.1 → 1.0.02024-01-13

### Community

Maintainers

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

---

Top Contributors

[![KingBes](https://avatars.githubusercontent.com/u/48203677?v=4)](https://github.com/KingBes "KingBes (11 commits)")

### Embed Badge

![Health badge](/badges/kingbes-attribute/health.svg)

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

PHPackages © 2026

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