$ show exposedev/expose
Expose is a command-line tunneling tool written in PHP using the Laravel Zero micro-framework and ReactPHP for asynchronous networking. It acts as an ngrok alternative, allowing developers to expose local HTTP servers and TCP ports to the public internet via a remote server. The application includes a CLI client for sharing sites, a local web dashboard (port 4040) for inspecting requests/responses, and a plugin system for analyzing webhook payloads (e.g., GitHub, Stripe, Paddle). The architecture is a monolith structured around a ReactPHP event loop: the client establishes a WebSocket control connection to the Expose server, authenticates, then creates proxy connections that forward incoming HTTP requests from the server to the local application. The local dashboard is served by an embedded HTTP server and uses a Vue 3 frontend with real-time WebSocket updates. The codebase demonstrates strong craftsmanship in areas like the plugin system, magic authentication flow, and custom terminal output handling, though some components are tightly coupled and the dependency on forked ReactPHP packages introduces moderate technical drift.
The LLM identified 3 files worth highlighting for reuse:
The PluginManager discovers, loads, and manages request plugins (Python-style plugin system). It scans default and custom plugin directories, validates plugin classes, and orchestrates plugin execution on each logged request. This component is cleanly decoupled from the rest of the application and could be extracted to build a generic PHP plugin system for HTTP request analysis.
Implements a complete 'magic authentication' flow that protects shared tunnels with an email-based login form. It issues signed cookies using HMAC-SHA256, validates them on subsequent requests, and supports email domain whitelisting. The implementation is self-contained (no deep framework coupling) and demonstrates a reusable pattern for HTTP ingress authentication.
A custom Symfony ConsoleSectionOutput subclass that provides overwritable terminal sections. This enables real-time updates of CLI output (e.g., request logs) without the overhead of clearing and redrawing the entire screen. The pattern is reusable for any CLI application that needs to maintain a dynamic terminal view while preserving previous output.