PHP code example of kingbes / attribute

1. Go to this page and download the library: Download kingbes/attribute library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kingbes / attribute example snippets


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") // 获取应用插件的注解信息

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());
    }
}