After this short introduction in the development with WebSockets, let us now begin implementing the actual chat application. The chat application will consist of the server-side application built in PHP with Ratchet, and an HTML and JavaScript-based client that will run in the user's browser.
As mentioned in the previous section, applications based on ReactPHP will achieve the best performance when used with an event-loop extension such as libevent
or ev
. Unfortunately, the libevent
extension is not compatible with PHP 7, yet. Luckily, ReactPHP also works with the ev
extension, whose latest version already supports PHP 7. Just like in the previous chapter, we'll be working with Docker in order to have a clean software stack to work on. Start by creating a Dockerfile for your application container:
FROM php:7 RUN pecl install ev-beta && \ docker-php-ext-enable ev WORKDIR /opt/app CMD ["/usr/local/bin/php...