The above diagram shows the any external php file or database layer changes has happen should be notify to all our web client.
We can able to achieve this using React/ZMQ
Requirements
ZeroMQ
All Our client web pages will be listening to port 8080 for incoming WebSocket connections...but how will it also get updates from another PHP script or another server process event.
Enter ZeroMQ.
We could use raw sockets, like the ones Ratchet is built on, but ZeroMQ is a library that just makes sockets easier.
install zmq
React/ZMQ
Ratchet is a WebSocket library built on top of a socket library called React.
React handles connections and the raw I/O for Ratchet.
In addition to React, which comes with Ratchet, we need another library that is part of the React suite: React/ZMQ.
This library will bind ZeroMQ sockets to the Reactor core enabling us to handle both WebSockets and ZeroMQ sockets.
To install, your composer.json file should look like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP ZMQ extension we will look at how you can easily distribute work to background processes, provide flexible service brokering for your next service oriented architecture, and manage caches efficiently and easily with just PHP and the ZeroMQ libraries. Whether the problem is asynchronous communication, message distribution, process management or just about anything, ZeroMQ can help you build an architecture that is more resilient, more scalable and more flexible, without introducing unnecessary overhead or requiring a heavyweight queue manager node..
Installing ZMQ in Windows
Required Softwares Apache 2.4 & PHP 5.6
Download the zmq php extension from following url depends up on the installed php version
url: ZMq Download Url
Extract the folder
Copy the php_zmq.dll to php/ext directory
Then copy the libzmq.dll to the php/ root directory
Add below line in php.ini file : extension=php_zmq.dll