Bridging Ratchet and PSR-7 applications
Sooner or later, your chat application will also need to respond to regular HTTP requests (for example, this will become necessary as soon as you want to add an authentication layer with a login form and authentication processing).
As explained in the previous section, a common setup for WebSocket applications in PHP is to have a Ratchet application handle all WebSocket connections, and to direct all regular HTTP requests to a regular PHP-FPM setup. However, as a Ratchet application in fact also ships its own HTTP server, you can also respond to regular HTTP requests directly from your Ratchet application.
Just as you have used the Ratchet\MessageComponentInterface
to implement WebSocket applications, you ...
Get PHP 7 Programming Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.