hhxsv5/laravel-s
65.4
Adequate · 19 September 2026
4.8k
lines of production code
PHP
primary language
1
measurement over time
What this system is
This system is a LaravelS integration layer that bridges the Laravel framework with the Swoole coroutine server to enable high-performance, long-running HTTP and WebSocket applications. It provides infrastructure for managing the Swoole lifecycle, including custom background processes, asynchronous task dispatching, and global timer coordination with Redis locking. To ensure stability in a persistent environment, it implements request-scoped state cleaners and coroutine-local context storage to prevent data leakage between requests. Additionally, it offers built-in observability through Prometheus metrics collection and dynamic configuration management via Apollo.
How it got here
2018 — Initial LaravelS integration and Swoole foundation
13 changes.
This period established the core LaravelS integration layer, bridging the Swoole HTTP server with the Laravel framework to handle HTTP and WebSocket requests. It introduced foundational components for asynchronous task dispatching, coroutine-local context storage, and custom process management, while refactoring request handling to prevent state leakage. The work also added infrastructure for lifecycle event hooks, file watching, and configuration management to support a robust, high-performance server environment.
2019–2025 — Swoole runtime and observability features
6 changes.
This period focused on enhancing the Swoole-based runtime by introducing request-scoped cleaners to prevent state leakage and a coroutine-aware HTTP client for improved performance. It also added comprehensive observability through Prometheus metrics collection and integrated Apollo for dynamic configuration management, while ensuring compatibility with PHP 8.2+.
Features
Add Prometheus metrics collection for LaravelS applications
Introduces a new Prometheus integration that automatically collects and exposes metrics for Swoole workers, system resources, and HTTP requests. The change adds a service provider to register collectors (HTTP, Swoole process/stats, system) and an exporter that renders APCu-backed metrics in Prometheus text format. A background collector process and a timer-based cron job handle periodic metric gathering, while a request middleware captures per-request data after the response is sent.
src/Components/Prometheus · high confidence
Added coroutine-aware HTTP client trait
A new \SimpleHttpTrait\ has been introduced in the \HttpClient\ component to provide a unified interface for making HTTP GET requests. This trait automatically detects if the code is running within a Swoole coroutine context; if so, it utilizes Swoole's native coroutine HTTP client for non-blocking performance, otherwise it falls back to standard cURL. The implementation handles response parsing, header extraction, and timeout configuration, ensuring consistent behavior regardless of the execution environment.
src/Components/HttpClient · high confidence
Added coroutine-local context storage for LaravelS
A new \Context\ class has been introduced in the \src/Swoole/Coroutine\ directory to provide coroutine-local storage capabilities within the LaravelS framework. This component allows data to be stored and retrieved on a per-coroutine basis using Swoole's coroutine ID, ensuring that context variables remain isolated between concurrent coroutines. It includes methods to get, put, and delete context items, as well as a utility to check if the current execution is inside a coroutine, facilitating better state management in asynchronous Swoole applications.
src/Swoole/Coroutine · high confidence
Initial release of LaravelS integration layer
This change introduces the core \LaravelS\ class, which bridges the Swoole HTTP server with the Laravel framework. It enables the handling of HTTP and WebSocket requests by converting Swoole requests to Laravel requests, managing the Laravel application lifecycle (including session persistence on WebSocket open), and firing specific lifecycle events such as ServerStart, ServerStop, WorkerStart, WorkerStop, and WorkerError. The implementation also integrates support for custom processes, inotify-based file watching for hot reloading, and timer processes.
src · high confidence
Introduce Apollo configuration management component
Adds a new Apollo component to the application, introducing a Client class for fetching and saving configuration data from an Apollo server and a Process class that runs as a background worker to watch for configuration changes and trigger application reloads. The component supports initialization via environment variables or command-line options, handles namespace-based configuration pulling, and automatically updates the .env file while backing up previous versions if configured.
src/Components/Apollo · high confidence
Introduce Swoole-based async task and event dispatching
Added new abstract classes (BaseTask, Task, Event, Listener) in src/Swoole/Task that enable asynchronous task execution and event handling via Swoole. Tasks and events can now be delayed using a configurable delay in seconds and support retry logic via a configurable number of tries. The implementation uses Swoole's task queue for immediate delivery and Timer::after for delayed execution, ensuring compatibility with Swoole's worker model.
src/Swoole/Task · high confidence
Introduce Symfony-based LaravelS console command with environment and Apollo support
The \src/Console/Portal.php\ file introduces a new Symfony Console-based entry point for the LaravelS tool, replacing or augmenting previous command structures. This change adds the \--env\ option to allow users to specify the environment file (e.g., \.env.production\) at startup, and the \--x-version\ option to inject a project version into the server environment. It also integrates Apollo configuration support via \Client::attachCommandOptions\ and \loadApollo\, enabling dynamic config loading. The command now checks for both \swoole\ and \openswoole\ extensions, supports daemon mode, and provides a structured interface for start, stop, restart, reload, and info actions.
src/Console · high confidence
Introduce request-scoped cleaners to reset Laravel state between requests
This change adds a suite of cleaner classes (AuthCleaner, ConfigCleaner, ContainerCleaner, CookieCleaner, DcatAdminCleaner, JWTCleaner, LaravelAdminCleaner, MenuCleaner, RequestCleaner, SessionCleaner, and ZiggyCleaner) to the src/Illuminate/Cleaners directory. These components are designed to reset specific application states—such as authentication guards, session drivers, container rebound callbacks, and third-party admin panel instances—after each request. This ensures that static or singleton state from one request does not leak into subsequent requests in long-running Swoole processes.
src/Illuminate/Cleaners · high confidence
Introduces a global timer mechanism with Redis-based locking and health checks
The Swoole Timer component now supports a global timer mode that uses Redis to coordinate timer execution across multiple processes. This is achieved by introducing a new \CronJob\ abstract class and specific implementations: \BackupCronJob\ prevents the timer process from exiting when no other timers are active, \RenewGlobalTimerLockCronJob\ maintains the Redis lock to keep the timer alive, and \CheckGlobalTimerAliveCronJob\ verifies the lock's validity. The \TimerTrait\ now conditionally registers these auxiliary jobs when \global\_lock\ is enabled in the configuration, ensuring that only one instance executes the primary timer logic at a time while others monitor its health.
src/Swoole/Timer · high confidence
Introduces abstract socket classes and interfaces for HTTP, TCP, UDP, and WebSocket protocols
The \src/Swoole/Socket\ directory now provides a structured foundation for handling different network protocols by introducing abstract base classes (\Http\, \TcpSocket\, \UdpSocket\, \WebSocket\) and corresponding interfaces (\HttpInterface\, \TcpInterface\, \UdpInterface\, \WebSocketInterface\, \PortInterface\). These components define standard event signatures for Swoole server ports, such as \onConnect\, \onReceive\, \onMessage\, and \onPacket\, allowing developers to extend these classes to implement custom protocol handlers within the LaravelS framework.
src/Swoole/Socket · high confidence
New Prometheus collectors for HTTP, Swoole, and system metrics
Added four new metric collectors to the Prometheus integration: HttpRequestCollector tracks HTTP request counts, sums, and maximum durations using APCu with a configurable time window (default 60s); SwooleProcessCollector exposes per-process memory usage and garbage collection statistics; SwooleStatsCollector reports Swoole server stats including worker/task counts and connection numbers; and SystemCollector provides system load averages. These collectors enable detailed monitoring of application performance and infrastructure health via Prometheus.
src/Components/Prometheus/Collectors · high confidence
New Swoole lifecycle event interfaces for server and worker phases
The \src/Swoole/Events\ directory now includes new interfaces (\ServerStartInterface\, \ServerStopInterface\, \WorkerStartInterface\, \WorkerStopInterface\, and \WorkerErrorInterface\) that allow developers to hook into specific Swoole server and worker lifecycle events. These interfaces define the expected method signatures for handling server start/stop and worker start/stop/error events, enabling custom logic to be executed at these critical points in the Swoole process lifecycle.
src/Swoole/Events · high confidence
New bin scripts for file watching and LaravelS management
Added executable scripts in the bin directory to streamline development workflows: \bin/fswatch\ and \bin/inotify\ now automatically monitor PHP file changes in a specified working directory and trigger a LaravelS reload, while \bin/laravels\ provides a standalone entry point to manage the LaravelS process (start, restart, reload) with an optimized autoloader that explicitly registers Symfony dependencies to resolve class-loading issues.
bin · high confidence
New configuration files for LaravelS and Prometheus metrics
This change introduces two new configuration files: \config/laravels.php\ and \config/prometheus.php\. The \laravels.php\ file provides a centralized configuration for the LaravelS Swoole server, allowing users to adjust server settings such as listen IP/port, socket type, static resource handling, inotify reload behavior, event handlers, WebSocket support, custom processes, and timer-based cron jobs. The \prometheus.php\ file enables Prometheus metrics collection, with configurable options to enable/disable the collector, set the application name, manage APCu key prefixes and TTLs, define time windows for max duration metrics, ignore specific HTTP status codes, and set the metrics collection interval.
config · high confidence
Support for custom Swoole processes with reload and restart capabilities
Users can now define and run custom background processes within the LaravelS application. This change introduces a \CustomProcessInterface\ that requires a \callback\ method for the main process logic and an \onReload\ method to handle graceful reloading via the SIGUSR1 signal. The implementation in \CustomProcessTrait\ allows configuring multiple process instances, setting restart intervals when a process exits, and optionally enabling message queues. It also ensures process titles are set correctly across different environments (using \cli\_set\_process\_title\ or \swoole\_set\_process\_name\) and manages PID files for monitoring.
src/Swoole/Process · high confidence
Behavioural changes
Refactored request cleanup and provider registration into modular components
The monolithic request handling logic in \src/Illuminate/Laravel.php\ has been split into dedicated classes to improve maintainability and fix state-leakage issues between requests. A new \CleanerManager\ now centralizes the cleanup of the application container, configuration, cookies, and requests via pluggable \CleanerInterface\ implementations, while a \ReflectionApp\ class encapsulates the reflection-based logic required to safely re-register service providers and manage the \loadedProviders\ state across different Laravel and Lumen versions. Additionally, a new \ListPropertiesCommand\ has been added to help developers identify controller properties that may persist across requests due to the singleton nature of the Swoole workers.
src/Illuminate · high confidence
Support for PHP 8.2+ dynamic properties in Swoole server proxies
Added HttpServerProxy and WebSocketServerProxy classes that extend Swoole's native Server classes and are annotated with the \#\[\\AllowDynamicProperties\] attribute. This change ensures compatibility with PHP 8.2+ by allowing dynamic properties on these server instances, which is required for features like Swoole Tables that rely on dynamic property assignment.
src/Swoole/Proxy · high confidence
Swoole integration refactored with new request/response handling and file watch support
The Swoole server layer has been restructured to improve request handling, response streaming, and development workflow. Request parsing now correctly maps HTTP headers to $\_SERVER variables and fixes the REQUEST\_URI construction. Response handling is split into specialized classes: DynamicResponse supports chunked streaming for large or streamed content, StaticResponse uses sendfile for efficient file delivery, and the base Response class now supports HTTP trailers and raw cookies. Additionally, a new Inotify-based file watcher allows automatic application reloading when source files change, configurable by file type and excluded directories.
src/Swoole · high confidence
Test coverage
Added HTTP client and performance testing infrastructure
Added a new PHPUnit test suite for the SimpleHttpTrait to verify HTTP GET requests, including a base TestCase class. Additionally, introduced an avg-qps.sh script to benchmark average queries per second using Apache Bench (ab).
tests · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 65.
Lenses
- Code Health 96
- Architecture 96
- Maturity 57
- Readiness 55
- Security 90
Changes since last survey
- 300 commits — 231 feature/other, 69 fixes
By area
- (root) — 118 commits
- src/Components — 50 commits
- src/Swoole — 31 commits
- (repo) — 27 commits
- src/Illuminate — 23 commits
- config/laravels.php — 16 commits
- src/Console — 12 commits
- src/LaravelS.php — 9 commits
- config/prometheus.php — 5 commits
- bin/laravels — 3 commits
- .github/FUNDING.yml — 2 commits
- .github/ISSUE_TEMPLATE — 2 commits
- tests/avg-qps.sh — 2 commits
Notable commits
- fix: Fix badge link for latest version in README-CN.md
- fix: Fix the type conversion of cookie value and domain name in Response class to ensure they are a string type
- fix: Fixed --env option, optimize dashboard
- fix: Merge pull request #376 from hhxsv5/revert-375-master
- fix: Merge pull request #463 from summerKK/fix-register-providers-20231213
- fix: Merge pull request #496 from PrintNow/fix-issues-495
- fix: Merge pull request #504 from PrintNow/fix/php82-dynamic-properties
- fix: Revert "fix return values"
- fix: Revert "give up compatibility with Open Swoole, due to the lack of some constants and methods, such as SWOOLE_VERSION, swoole_cpu_num()"
- fix: Revert "implementation of multiple processes creation"
- fix: Revert "upgrade bug_report.md"
- fix: fix #288 #362
- fix: fix #330
- fix: fix #341
- fix: fix #352
- fix: fix #364
- fix: fix #437
- fix: fix #437
- fix: fix $request->route()
- fix: fix FUNDING.yml
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
hhxsv5/laravel-s was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit aac9fb39350a182eb80e2086a7452ef60cd0aa68 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.