$ show easy-swoole/easyswoole
EasySwoole is a high-performance PHP framework built on the Swoole extension, designed for building distributed, persistent-memory API services. It provides a complete server abstraction (HTTP, WebSocket, TCP) with coroutine support, along with built-in components for configuration management, logging, error handling, process management, task workers, crontab scheduling, and inter-process communication via Unix sockets. The framework includes a powerful CLI for server lifecycle management (start/stop/reload/status), process inspection, crontab control, and task worker rolling reloads. Its architecture is modular, using singletons, dependency injection, and event-driven hooks, and it ships with a comprehensive test suite. The codebase is written in a non-standard PHP dialect (likely transpiled), which may limit direct reuse in standard PHP projects, but the patterns and design are well-considered.
The LLM identified 4 files worth highlighting for reuse:
Manages terminal raw mode, key reading, and dimension detection for interactive CLI sessions. It handles state restoration on shutdown, supports stty-based configuration, and provides a clean API for reading keys with timeout. This class is fully self-contained (no internal framework dependencies) and could be extracted as a standalone terminal utility for any PHP CLI application.
Provides an interactive selection menu with both arrow-key navigation and numbered fallback for non-terminal environments. It handles viewport limiting, rendering with ANSI escape codes, and supports multi-select, toggle all, and cancellation. The class is abstract and designed to be extended with domain-specific labels and details. It depends only on the Terminal class and could be reused in any PHP CLI tool requiring user selection.
Base class for bridge commands that uses reflection to dispatch incoming IPC requests to public methods. It includes a forbid list to prevent exposure of internal methods (e.g., exec, __construct, static methods) and validates arguments. This pattern is cleanly separated from the transport layer and could be extracted to implement command handlers in any IPC or RPC system.
A container for registering event callbacks with a predefined set of allowed event names (derived from class constants). Supports setting (replace) and adding (append) callbacks, and retrieving all registered events. It is a simple, well-encapsulated implementation of the observer pattern that could be reused in any PHP application needing structured event registration.