phrity/websocket
WebSocket client and multi-connection server for PHP, supporting ws/wss, listener callbacks, close and ping/pong handling, optional deflate compression, message fragmentation, and custom opcodes.
laravel-websockets-style implementations or custom endpoints; client-side consumption in jobs/queues.CloseHandler, PingResponder, and DeflateCompression remain the extension points. Behavioural change: compression failures now raise MessageEncodingException rather than surfacing as a silent/ambiguous encoding fault — this must be handled explicitly inside the middleware chain or it will bubble into the connection loop.Client and Server are configured — every constructor/options array assembled in the provider or config/websockets.php needs review against the v3→v4 migration guide.Server::onText() → Laravel events is unaffected. Connection enumeration is affected: getConnections() now returns a Connections collection instead of an array.3.x.~3.7. That guidance must now be split: ~3.8 (or ^3.7) for teams not yet migrated, ^4.0 only after a completed migration. Do not allow a floating constraint across the 3→4 boundary.nyholm/psr7 version pinned by your Laravel framework release. Must be verified with composer why-not nyholm/psr7 before committing to v4.catch blocks — a catch (WebSocket\Exception\...) that no longer matches will let failures escape to Laravel’s global handler and, in a server context, potentially terminate the connection loop.getConnections() type change: Any code doing array_filter, array_map, count() semantics, or type-hinting array will fail at runtime, not at static analysis time unless typed strictly.composer.json before it is assumed unchanged.3.8.x receiving security fixes, or is v4 the only supported line?Client/Server configuration directly vs. only the high-level send/receive API? The former determines effort.laravel/framework and nyholm/psr7 versions?Handler::$dontReport and our alerting rules?MessageEncodingException is a non-event; if yes, it is a new failure path requiring handling.Connections collection materially heavier than the prior array for per-tick enumeration?nyholm/psr7 / Nyholm PSR HTTP is now a direct dependency rather than an internal stub. Resolution against the framework’s pinned version is the first gate.phrity/net-stream remains low-level and non-conflicting.php artisan websocket:start and a Route::websocket() macro remain valid. Add a migration diagnostic command (e.g. websocket:diagnose) that reports pinned version, resolved Nyholm version, and any configured options keys that no longer exist in v4 — this pays for itself during rollout.~3.8 repo-wide to stop accidental 3→4 drift. Inventory every Client/Server construction site, every catch on a WebSocket exception, and every consumer of getConnections().getConnections() consumers from array semantics to iterable/collection semantics. This is mechanical but easy to miss.MessageEncodingException handling in DeflateCompression.composer.json to ^4.0, delete the temporary pin, and remove any v3 compatibility shims.~3.8, open a migration epic, assign an owner, capture the v3 EOL answer.getConnections() consumers ahead of the server cutover.^4.0, remove shims, close the epic.~3.8 legacy, ^4.0 migrated). Enforce via a Composer constraint check in CI so a transitive bump cannot cross the major boundary unnoticed.#162–#165); expect follow-up patch churn on the new exception and Nyholm paths. Budget for at least one point release before treating v4 as fully stable.Log facade. Update log-parsing rules to recognise the new exception class names.MessageEncodingException deserves its own alert — it indicates message corruption on the wire, which is a signal worth page-worthy attention rather than a generic error counter increment.onError() hooks and Telescope integration carry over. Telescope’s exception capture will group on the new class names, so historical dashboards will look discontinuous across the migration — annotate deploys.composer.lock.pcntl_fork.getConnections() return-type change has a mild but real scaling implication. If you broadcast by iterating all connections on a timer, measure the collection’s per-tick cost at peak connection count against the previous array implementation. Iteration is fine; if the collection is rebuilt per call, per-tick allocation grows with connection count.setMaxConnections() guidance stands; re-verify the option key against v4’s configuration surface.| Failure | Impact | Mitigation |
|---|---|---|
| 3→4 upgrade attempted without migration | Fatal errors on boot; server fails to start | Hard-pin ~3.8; require the migration epic to close before the constraint moves |
Renamed exception escapes old catch |
Failure propagates to Laravel’s global handler; server loop may terminate | Audit every catch against the v4 hierarchy; add a static-analysis rule or grep gate in CI |
getConnections() array semantics |
Runtime TypeError / silent logic errors in broadcast paths |
Refactor to iterable/collection semantics in Phase 2, before the server cutover |
| Nyholm version conflict | composer update fails or framework pinned back |
Pre-flight resolution test; document the pin |
MessageEncodingException unhandled |
Connection-level failure on compressed payloads | Explicit try/catch in DeflateCompression middleware; dedicated alert |
| v3 goes unpatched while migration stalls | Unpatched security exposure in a long-lived process | Get the v3 EOL answer in Phase 0; set a migration deadline against it |
| WebSocket disconnection | Lost real-time updates | Reconnection logic (unchanged) |
| Server crash | Downtime for all WebSocket users | Forge/Envoyer auto-restart (unchanged) |
| Memory leak under sustained load | Server instability | Blackfire/Debugbar monitoring; re-baseline after v4 given the object-model changes |
getConnections() type. Laravel-specific examples (middleware wiring, provider config) still need writing.onOpen/onClose) carries over unchanged.php artisan tinker for interactive client testing and a health check on the up command remain valid; add the websocket:diagnose command described above so version/config drift is visible at a glance.How can I help you explore Laravel packages today?