Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

thinkphpthinkphp 搜索

Agent Skill

thinkphp 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

404

周安装

17

GitHub Stars

11

下载量

141
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:thinkphp(thinkphp 搜索)
来源仓库:https://github.com/youlaitech/youlai-skills
仓库路径:skills/thinkphp
安装命令:
npx skills add https://github.com/youlaitech/youlai-skills --skill thinkphp
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/youlaitech/youlai-skills --skill thinkphp

简介

thinkphp 搜索用于查找、检索和筛选相关信息。

  • 适合在 Codex、Claude、Cursor 等宿主中根据关键词快速定位结果。
  • 通过 npx 安装并指定技能,可结合来源仓库进一步核验用法。
  • 使用前需确认权限范围、维护状态及是否触发联网或文件操作。
  • thinkphp 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

ThinkPHP 后端开发规范

参考:ThinkPHP 8.0 开发规范 | ThinkPHP 8.0 目录结构

触发条件

  • 开发 ThinkPHP 项目
  • 实现 REST API
  • 使用模型数据访问
  • 实现 JWT 认证
  • 实现权限控制

Part 1: 技术栈

  • PHP - 运行环境
  • ThinkPHP - Web 框架
  • MySQL - 数据库
  • Redis - 缓存
  • firebase/php-jwt - Token 认证

Part 2: 目录结构

参考:ThinkPHP 8.0 目录结构
app/
├─ BaseController.php          # 基础控制器类(官方推荐位置)
├─ ExceptionHandle.php         # 应用异常处理
├─ common.php                  # 全局公共函数
├─ middleware.php              # 全局中间件定义
├─ provider.php                # 服务提供定义
├─ event.php                   # 全局事件定义
│
├─ auth/                       # 认证模块(目录使用小写)
│  ├─ controller/              # 控制器目录
│  ├─ service/                 # 服务目录
│  └─ validate/                # 验证器目录
│
├─ system/                     # 系统模块(目录使用小写)
│  ├─ controller/              # 控制器目录
│  ├─ service/                 # 服务目录
│  ├─ model/                   # 模型目录
│  └─ validate/                # 验证器目录
│
├─ file/                       # 文件模块
├─ codegen/                    # 代码生成模块
│
├─ common/                     # 公共代码(非模块)
│  ├─ constants/               # 常量定义
│  ├─ enums/                   # 枚举类
│  ├─ exception/               # 异常类
│  ├─ redis/                   # Redis 工具
│  ├─ security/                # 认证/权限
│  ├─ util/                    # 工具类
│  └─ web/                     # Web 相关
│
├─ middleware/                 # 全局中间件
├─ traits/                     # 复用特性
└─ websocket/                  # WebSocket

Part 3: 命名规范

参考:ThinkPHP 8.0 开发规范

目录和文件

规则示例
目录使用小写+下划线controller/, user_service/
类库、函数文件统一以 .php 为后缀UserController.php
类的文件名与命名空间路径一致app\system\controller\UserControllerapp/system/controller/UserController.php
类文件采用驼峰法命名(首字母大写)UserController.php, UserType.php
其它文件采用小写+下划线命名common.php, route.php

类命名

规则示例
类名采用驼峰法(首字母大写)User, UserType, UserController
类名与文件名保持一致UserController 类 → UserController.php

方法和属性命名

规则示例
方法采用驼峰法(首字母小写)getUserName(), getUserById()
属性采用驼峰法(首字母小写)$tableName, $instance
魔术方法以双下划线开头__call(), __autoload()

函数命名

规则示例
函数使用小写字母和下划线get_client_ip(), array_to_tree()

常量和配置

类型规则示例
常量大写字母和下划线APP_PATH, HAS_ONE
配置参数小写字母和下划线url_route_on, url_convert
环境变量大写字母和下划线APP_DEBUG, DB_HOST

数据表和字段

规则示例
数据表采用小写+下划线sys_user, sys_role_menu
字段采用小写+下划线user_name, created_at
禁止使用驼峰和中文命名userName, ❌ 用户表

Part 4: RESTful API 规范

标准 CRUD 路径

操作方法路径
分页列表GET/api/v1/users/page
详情GET/api/v1/users/:id
新增POST/api/v1/users
更新PUT/api/v1/users
删除DELETE/api/v1/users/:id
批量删除DELETE/api/v1/users/batch
下拉选项GET/api/v1/users/options

Controller 模板

<?php
declare(strict_types=1);

namespace app\system\controller;

use app\BaseController;
use app\system\model\User;
use app\system\validate\UserValidate;
use app\common\exception\BusinessException;
use app\common\web\ResultCode;
use think\facade\Request;

final class UserController extends BaseController
{
    protected bool $requireAuth = true;

    /**
     * 用户分页列表
     */
    public function page()
    {
        $params = $this->request->get();
        $result = User::where(function ($query) use ($params) {
            if (!empty($params['keywords'])) {
                $query->whereLike('username|nickname', $params['keywords']);
            }
            if (isset($params['status'])) {
                $query->where('status', $params['status']);
            }
        })
        ->order('create_time', 'desc')
        ->paginate([
            'page' => $params['pageNum'] ?? 1,
            'list_rows' => $params['pageSize'] ?? 20,
        ]);

        return $this->successPaginate($result->items(), $result->total());
    }

    /**
     * 用户详情
     */
    public function detail($id)
    {
        $user = User::find($id);
        if (!$user) {
            throw new BusinessException(ResultCode::USER_ERROR);
        }
        return $this->success($user->toArray());
    }

    /**
     * 新增用户
     */
    public function create()
    {
        $params = $this->request->post();
        $this->validate($params, UserValidate::class, 'create');

        // 检查用户名是否存在
        if (User::where('username', $params['username'])->find()) {
            throw new BusinessException(ResultCode::USER_ERROR, '用户名已存在');
        }

        $user = new User();
        $user->username = $params['username'];
        $user->password = password_hash($params['password'], PASSWORD_BCRYPT);
        $user->nickname = $params['nickname'];
        $user->mobile = $params['mobile'] ?? '';
        $user->email = $params['email'] ?? '';
        $user->status = $params['status'] ?? 1;
        $user->save();

        return $this->success(['id' => $user->id]);
    }

    /**
     * 更新用户
     */
    public function update()
    {
        $params = $this->request->put();
        $this->validate($params, UserValidate::class, 'update');

        $user = User::find($params['id']);
        if (!$user) {
            throw new BusinessException(ResultCode::USER_ERROR);
        }

        $user->nickname = $params['nickname'];
        $user->mobile = $params['mobile'] ?? '';
        $user->email = $params['email'] ?? '';
        $user->status = $params['status'] ?? 1;
        $user->save();

        return $this->success();
    }

    /**
     * 删除用户
     */
    public function delete($id)
    {
        $user = User::find($id);
        if (!$user) {
            throw new BusinessException(ResultCode::USER_ERROR);
        }
        $user->delete();
        return $this->success();
    }

    /**
     * 批量删除
     */
    public function batchDelete()
    {
        $ids = $this->request->delete('ids');
        User::destroy($ids);
        return $this->success();
    }

    /**
     * 用户选项列表
     */
    public function options()
    {
        $list = User::field('id, nickname')->select();
        return $this->success($list->toArray());
    }
}

Part 5: 响应格式

参考:接口协议
<?php
declare(strict_types=1);

namespace app\common\web;

use think\response\Json;

class Result
{
    public static function success(mixed $data = null, string $msg = '成功'): array
    {
        return [
            'code' => '00000',
            'msg' => $msg,
            'data' => $data,
        ];
    }

    public static function page(array $list, int $total): array
    {
        return [
            'code' => '00000',
            'msg' => '成功',
            'data' => [
                'list' => $list,
                'total' => $total,
            ],
        ];
    }

    public static function failedWith(ResultCode $code, string $msg = ''): array
    {
        return [
            'code' => $code->value,
            'msg' => $msg ?: $code->getMsg(),
            'data' => null,
        ];
    }
}

BaseController 响应方法

<?php
declare(strict_types=1);

namespace app;

use app\common\web\Result;
use app\common\web\ResultCode;
use think\App;
use think\response\Json;

abstract class BaseController
{
    protected App $app;
    protected $request;
    protected bool $requireAuth = false;

    public function __construct(App $app)
    {
        $this->app = $app;
        $this->request = $app->request;
        $this->initialize();
    }

    protected function initialize(): void
    {
        if ($this->requireAuth && $this->getAuthUserId() <= 0) {
            throw new BusinessException(ResultCode::ACCESS_TOKEN_INVALID);
        }
    }

    protected function success(mixed $data = null, string $msg = ''): Json
    {
        return json(Result::success($data, $msg ?: ResultCode::SUCCESS->getMsg()));
    }

    protected function successPaginate(array $list, int $total): Json
    {
        return json(Result::page($list, $total));
    }

    protected function fail(ResultCode $code, string $msg = ''): Json
    {
        return json(Result::failedWith($code, $msg));
    }
}

Part 6: 模型规范

基础模型

<?php
declare(strict_types=1);

namespace app\common\model;

use think\Model;

class BaseModel extends Model
{
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    use \think\model\concern\SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;

    public static function onBeforeInsert($model): void
    {
        $model->create_by = request()->userId ?? 0;
        $model->update_by = request()->userId ?? 0;
    }

    public static function onBeforeUpdate($model): void
    {
        $model->update_by = request()->userId ?? 0;
    }
}

模型示例

<?php
declare(strict_types=1);

namespace app\system\model;

use app\common\model\BaseModel;

final class User extends BaseModel
{
    protected $name = 'sys_user';
    protected $pk = 'id';

    protected $hidden = ['password', 'delete_time'];

    protected $type = [
        'id' => 'integer',
        'status' => 'integer',
        'create_time' => 'datetime',
        'update_time' => 'datetime',
    ];

    public function dept()
    {
        return $this->belongsTo(Dept::class, 'dept_id');
    }

    public function roles()
    {
        return $this->belongsToMany(Role::class, UserRole::class, 'role_id', 'user_id');
    }
}

Part 7: 路由规范

<?php
use think\facade\Route;

// 认证接口(无需登录)
Route::group('api/v1/auth', function () {
    Route::post('login', 'auth.controller.AuthController/login');
    Route::post('logout', 'auth.controller.AuthController/logout');
    Route::post('refresh-token', 'auth.controller.AuthController/refreshToken');
})->allowCrossDomain();

// 需要登录的接口
Route::group('api/v1', function () {
    // 用户管理
    Route::group('users', function () {
        Route::get('page', 'system.controller.UserController/page');
        Route::get(':id', 'system.controller.UserController/detail');
        Route::get('options', 'system.controller.UserController/options');
        Route::post('', 'system.controller.UserController/create');
        Route::put('', 'system.controller.UserController/update');
        Route::delete(':id', 'system.controller.UserController/delete');
        Route::delete('batch', 'system.controller.UserController/batchDelete');
    });

    // 角色管理
    Route::group('roles', function () {
        Route::get('page', 'system.controller.RoleController/page');
        // ...
    });
})->middleware(\app\middleware\Auth::class)
  ->allowCrossDomain();

Part 8: 认证规范

JWT 服务

<?php
declare(strict_types=1);

namespace app\common\security;

use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use think\facade\Config;

final class JwtService
{
    public static function generateAccessToken(array $payload): string
    {
        $payload['exp'] = time() + Config::get('jwt.access_ttl', 7200);
        $payload['iat'] = time();
        $payload['iss'] = Config::get('jwt.issuer', 'youlai-think');

        return JWT::encode($payload, Config::get('jwt.secret'), 'HS256');
    }

    public static function parseToken(string $token): ?array
    {
        try {
            $decoded = JWT::decode($token, new Key(Config::get('jwt.secret'), 'HS256'));
            return (array) $decoded;
        } catch (\Exception $e) {
            return null;
        }
    }

    public static function generateRefreshToken(int $userId): string
    {
        return JWT::encode([
            'sub' => $userId,
            'type' => 'refresh',
            'exp' => time() + Config::get('jwt.refresh_ttl', 604800),
        ], Config::get('jwt.secret'), 'HS256');
    }
}

认证中间件

<?php
declare(strict_types=1);

namespace app\middleware;

use app\common\security\JwtService;
use app\common\web\ResultCode;
use app\common\web\Result;
use Closure;
use think\Request;
use think\Response;

final class Auth
{
    public function handle(Request $request, Closure $next): Response
    {
        $token = $request->header('Authorization', '');
        $token = str_replace('Bearer ', '', $token);

        if (empty($token)) {
            return json(Result::failedWith(ResultCode::ACCESS_TOKEN_INVALID));
        }

        $payload = JwtService::parseToken($token);
        if (!$payload) {
            return json(Result::failedWith(ResultCode::ACCESS_TOKEN_INVALID));
        }

        $request->userId = $payload['sub'];
        $request->username = $payload['username'] ?? '';

        return $next($request);
    }
}

Part 9: 验证器规范

<?php
declare(strict_types=1);

namespace app\system\validate;

use think\Validate;

final class UserValidate extends Validate
{
    protected $rule = [
        'id' => 'require|integer',
        'username' => 'require|max:50',
        'password' => 'require|min:6|max:20',
        'nickname' => 'require|max:50',
        'mobile' => 'mobile',
        'email' => 'email',
        'status' => 'in:0,1',
    ];

    protected $message = [
        'username.require' => '用户名不能为空',
        'username.max' => '用户名最多50个字符',
        'password.require' => '密码不能为空',
        'password.min' => '密码至少6个字符',
        'nickname.require' => '昵称不能为空',
        'mobile.mobile' => '手机号格式错误',
        'email.email' => '邮箱格式错误',
    ];

    protected $scene = [
        'create' => ['username', 'password', 'nickname', 'mobile', 'email', 'status'],
        'update' => ['id', 'nickname', 'mobile', 'email', 'status'],
    ];
}

Part 10: 代码质量检查清单

  • 目录使用小写+下划线
  • 类名采用驼峰法(首字母大写)
  • 方法采用驼峰法(首字母小写)
  • 数据表和字段采用小写+下划线
  • 遵循 RESTful API 路径规范
  • 使用统一响应格式(Result/ResultCode)
  • 模型继承 BaseModel
  • 使用软删除
  • 分页接口使用 successPaginate
  • 使用验证器校验参数
  • 路由显式映射
  • 中间件实现认证

参考资料

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.81%
按下载量换算52

Claude

31.02%
按下载量换算44

Cursor

20.61%
按下载量换算29

Gemini CLI

8.62%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills