Skip to content

Conversation

@niccolovettorello1997
Copy link

@niccolovettorello1997 niccolovettorello1997 commented Dec 1, 2025

PHP 8 WebSocket Example (Ratchet) — server + Pawl client

This PR adds a fully working WebSocket example compatible with PHP 8.3+ (including PHP 8.4), tested on Linux and macOS.

New example

examples/php8-demo/

Includes

  • server.php — minimal Ratchet WebSocket server
  • client.php — PHP client using Ratchet/Pawl for event-loop compatibility
  • composer.json — define dependencies
  • README.md — updated documentation and usage instructions

Highlights

  • Demonstrates modern Ratchet usage in PHP 8 environments
  • Fully self-contained example; no changes to Ratchet core
  • Uses Pawl client to integrate properly with the Ratchet event loop
  • Safe to merge; the client dependency is local to the example and does not affect Ratchet core or backward compatibility

Tested successfully with

OS PHP Version
Linux 8.3.x
macOS 8.4.x

@WyriHaximus
Copy link

  • client.php — PHP client using textalk/websocket

Have you considered https://github.com/ratchetphp/Pawl for the client instead of something that doesn't hook into the event loop?

@niccolovettorello1997 niccolovettorello1997 force-pushed the php8-demo branch 3 times, most recently from b21907b to 1b736a1 Compare December 1, 2025 18:40
@niccolovettorello1997
Copy link
Author

Hi @WyriHaximus , thanks for the suggestion!

I’ve updated the PHP client to use Ratchet/Pawl, which integrates cleanly with the event loop and keeps the example fully compatible with PHP 8.3+.

The example (examples/php8-demo/) now contains:

  • server.php — minimal Ratchet WebSocket server
  • client.php — Pawl-based client
  • composer.json — Pawl and Event Loop local dependencies
  • README.md — updated instructions, tested on Linux and macOS

Appreciate any further feedback you might have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants