Using PHP with WebSocket

Is it possible to use PHP with WebSocket? Let's figure out
16 October 2017   339

Unfortuantelly, PHP is not designed to work with WebSocket. You can connect it, but your code will be full of while (true) and fsock_open . And you have to have access to the shell to run the WS-server with php-cgi. 

You need to choose a language that supports threads / asynchronous communication. Now on the top is Node.js. In addition, better use dedicated libraries to support older browsers, etc. If you want to create one-to-all communication (eg chat, broadcast messaging), go one step further and use one of the Bayeuximplementations, for example: Faye.

The mod_proxy_wstunnel extension adds an extra layer to the WS server. Depending on the configuration, it can support DDoS, queue, load-balancing, local port swapping, and https support. But better use this for nginx.

Websockets are events, and PHP is poorly managed with it.

HHVM will not support PHP in future

Last HHVM release that commits to PHP5 support will be version 3.24.0
21 September 2017   334

Hip Hop Virtual Machine, engine for PHP by Facebook team will not target PHP 7, the most-recent major PHP release, but instead will focus on Hack, a PHP spinoff.

Trying to support both PHP7 and Hack would lead to undesirable compromises on both fronts. We plan to decouple ourselves even more from PHP, so that we can make Hack great without having to account for all of the oldest, darkest corners of PHP’s design. We want the freedom to make Hack even more performant, and ultimately make it the best web application language available.

Max Wang

HHVM team

Hip Hop team is working on some cool Hack-related features:

  • Finishing up Hack arrays. 
  • Eliminating destructors. 
  • Eliminating references. 

Learn more from official blog

What is Hip Hop Virtual Machine?

HipHop for PHP is a source code transpiler created by Facebook. HipHop programmatically turns source code written in PHP into optimized C ++ code, and then uses the g ++ compiler to compile it. HipHop includes a code translator, an alternative implementation of the PHP runtime environment, and many of the most common PHP extensions that C has been rewritten to improve performance.

HipHop was created by the developers of the social network Facebook to save the resources of their servers. The source code was  planned to be released on February 2, 2010 in the form of open source software. However, the release of the code was delayed due to problems with cleaning the source code from the Facebook-specific extensions. The project source code became available on February 20, 2010.