create-proxy

为 PHP 8.4 生成代理模式实现,侧重于访问控制、延迟加载、缓存与日志记录,并包含单元测试用例示例。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-proxy":https://skillpi.com/zh/skills/deepskill-324ac4c59e1d992cf763b7082896650af7eb8abef36bf48393c8c2ccc1958e4a。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PHP 8.4 生成代理模式实现,侧重于访问控制、延迟加载、缓存与日志记录,并包含单元测试用例示例。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: create-proxy
description: Generates Proxy pattern for PHP 8.4. Controls access, adds lazy loading, caching, logging. Includes unit tests.

Proxy Pattern Generator

Creates Proxy pattern infrastructure for controlling access to objects.

When to Use

Scenario Example
Lazy initialization Load expensive resources on first access
Access control Check permissions before delegating
Caching Cache results of expensive operations
Logging Log calls to real subject

Component Characteristics

Subject Interface

  • Defines operations
  • Shared by proxy and real subject
  • Enables transparent substitution

Real Subject

  • Actual implementation
  • Contains business logic
  • May be expensive to create

Proxy

  • Implements subject interface
  • Controls access to real subject
  • Adds additional behavior

Generation Process

Step 1: Generate Subject Interface

Path: src/Domain/{BoundedContext}/

  1. {Name}Interface.php — Operations contract

Step 2: Generate Proxy

Path: src/Infrastructure/{BoundedContext}/Proxy/

  1. Lazy{Name}Proxy.php — Lazy initialization
  2. Caching{Name}Proxy.php — Result caching
  3. AccessControl{Name}Proxy.php — Permission checks
  4. Logging{Name}Proxy.php — Call logging

Step 3: Generate Tests

  1. {ProxyName}Test.php — Proxy behavior verification

File Placement

Component Path
Subject Interface src/Domain/{BoundedContext}/
Real Subject src/Domain/ or src/Infrastructure/
Proxy src/Infrastructure/{BoundedContext}/Proxy/
Unit Tests tests/Unit/Infrastructure/{BoundedContext}/Proxy/

Naming Conventions

Component Pattern Example
Subject Interface {Name}Interface RepositoryInterface
Real Subject {Name} UserRepository
Proxy {Type}{Name}Proxy LazyUserRepositoryProxy
Test {ClassName}Test LazyUserRepositoryProxyTest

Quick Template Reference

Proxy

final class {Type}{Name}Proxy implements {Name}Interface
{
    private ?{Name}Interface $realSubject = null;

    public function __construct(
        private \Closure $factory
    ) {}

    public function {operation}({params}): {returnType}
    {
        {beforeBehavior}

        $result = $this->getRealSubject()->{operation}({args});

        {afterBehavior}

        return $result;
    }

    private function getRealSubject(): {Name}Interface
    {
        if ($this->realSubject === null) {
            $this->realSubject = ($this->factory)();
        }

        return $this->realSubject;
    }
}

Usage Example

// Lazy loading proxy
$repository = new LazyUserRepositoryProxy(
    fn() => new UserRepository($connection)
);

// Real subject created only on first call
$user = $repository->findById($id);

Common Proxies

Proxy Purpose
LazyLoadingProxy Defer expensive object creation
CachingProxy Cache method results
AccessControlProxy Check permissions before execution
LoggingProxy Log all method calls
MetricsProxy Collect performance metrics
RetryProxy Retry failed operations

Anti-patterns to Avoid

Anti-pattern Problem Solution
Proxy != Real Subject Behavior differs Proxy must be transparent
Heavy Proxy Too much logic Keep proxies focused
Missing Interface Can't substitute proxy Use shared interface
Leaky State Proxy state affects behavior Keep proxies stateless when possible
Multiple Responsibilities Proxy does many things One proxy, one concern

References

For complete PHP templates and examples, see:

  • references/templates.md — Lazy loading, caching, access control proxy templates
  • references/examples.md — Repository, service proxies with unit tests

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 PHP 代理模式生成能力,覆盖懒加载、缓存、访问控制、日志等常见场景
  • 包含单元测试,提升代码可靠性
  • 面向 PHP 开发者,具有明确的实用价值
触发精准95/100

亮点

  • description 清晰完整,准确描述功能边界
  • 触发词精准,覆盖核心能力点
结构规范88/100

待提升项

  • 文档过长 原报告严重程度:轻微

    SKILL.md 内容详实但篇幅较长,可能影响快速查阅

    改进建议:考虑将部分参考内容(如模板、示例)移至独立文件并通过引用链接,保持主文档简洁

亮点

  • 结构清晰,分步骤说明生成流程
  • 包含完整的使用示例和命名规范
  • 提供常见代理类型和反模式指导
执行可靠75/100

待提升项

  • 工具来源不明 原报告严重程度:轻微

    未明确说明生成代理所需的具体工具或依赖

    改进建议:补充说明是否需要特定 CLI 工具、Composer 包或其他依赖项

亮点

  • 提供详细的文件路径和命名规范,便于执行
  • 模板代码完整,可直接参考使用
证据可验 (前四项均值)86/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。