create-proxy

Proxy pattern implementation for PHP 8.4 focusing on access control, lazy loading, caching, and logging, with included unit test examples.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-proxy" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-324ac4c59e1d992cf763b7082896650af7eb8abef36bf48393c8c2ccc1958e4a. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Proxy pattern implementation for PHP 8.4 focusing on access control, lazy loading, caching, and logging, with included unit test examples.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Proxy pattern for PHP 8.4. Controls access, adds lazy loading, caching, logging. Includes unit tests.
Audience
| 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 |
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

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

Highlights

  • description 清晰完整,准确描述功能边界
  • 触发词精准,覆盖核心能力点
Structure and Standards88/100

Areas to improve

  • Document is too long Reported severity: Minor

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

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

Highlights

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

Areas to improve

  • 工具来源不明 Reported severity: Minor

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

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

Highlights

  • 提供详细的文件路径和命名规范,便于执行
  • 模板代码完整,可直接参考使用
Evidence Verifiability (mean of the first four)86/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

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

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.