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 can use the Ratchet\HttpServerInterface
to implement a regular HTTP server. As an example, consider the following class:
namespace Packt\Chp6\Http; use Guzzle\Http\Message\RequestInterface; use Ratchet\ConnectionInterface; use Ratchet\HttpServerInterface...