PHP Flyweight Pattern Generator
Generates memory-efficient Flyweight pattern infrastructure for PHP 8.4 applications using shared intrinsic state.
This skill automates the implementation of the Flyweight design pattern within PHP 8.4 projects, specifically tailored for memory-sensitive architectures and Clean Architecture principles. It generates the complete boilerplate required—including interfaces, concrete flyweight classes with immutable intrinsic state, and factory management—while adhering to Domain-Driven Design (DDD) standards. By centralizing shared objects and separating intrinsic from extrinsic state, it significantly reduces the memory footprint in scenarios involving large quantities of similar objects like UI icons, currency codes, or metadata.
主要功能
01PHP 8.4 readonly class support for immutable shared state
0245 GitHub stars
03DDD-compliant file placement in Domain and Infrastructure layers
04Automated Flyweight Factory generation for efficient object reuse
05Standardized naming conventions for interfaces and implementations
06Built-in unit tests to verify object sharing and behavior
使用场景
01Reducing memory overhead when handling massive collections of repetitive objects like UI icons or glyphs
02Standardizing immutable shared data such as currency codes, tax rates, or region configurations
03Optimizing performance in high-throughput backend services by minimizing object creation overhead