A wrapper module that supports caching, websocket and database functionalities
- PHP >= 5.4
- MySQL >= 4.1
- Redis >= 2.8
- ZMQ >= 4.0
(take note that all the PHP dependencies can be found in the composer.json file)
-
React (PHP)
Event-driven, non-blocking I/O with PHP (similar to the event-driven, non-blocking I/O of Node.js)
http://reactphp.org/ -
Ratchet (PHP)
Ratchet is a loosely coupled PHP library providing developers with tools to create real time, bi-directional applications between clients and servers over WebSockets.
http://socketo.me/
In order to increase the performance (optional), you can use this extension:
Libevent (an event notification library)
-
Predis Async (PHP)
Asynchronous (non-blocking) version of Predis, the full-featured PHP client library for Redis, built on top of React to handle evented I/O.
https://github.com/nrk/predis-async
In order to increase the performance (optional), you can use this extension:
PHP bindings for Hiredis (Redis client)
https://github.com/nrk/phpiredis -
ZMQ
ØMQ (also spelled ZeroMQ, 0MQ or ZMQ) is a high-performance asynchronous messaging library, aimed at use in scalable distributed or concurrent applications.
-
Redis
Redis is an open source, BSD licensed, advanced key-value cache and store.
http://redis.io/ -
Autobahn JS
Autobahn|JS is a subproject of Autobahn and provides an open-source implementation of The Web Application Messaging Protocol (WAMP).
WAMP runs on top of WebSocket and adds asynchronous Remote Procedure Calls and Publish & Subscribe.
http://autobahn.ws/js/
-
Download and install XAMPP
XAMPP is an easy to install Apache distribution containing MySQL, PHP, and Perl.
It also includes the Eclipse IDE.
https://www.apachefriends.org/index.html -
Install Redis
This is needed for server-side caching
refer to section:
Setting Up the Cache -
Install ZMQ
Although optional, this is used for server-side message queueing, push/pull, publish/subscribe
refer to section:
Setting Up Websockets -
Install Composer
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
https://getcomposer.org/download/
After you install composer, go to the directory of thecomposer.json
and type on the command line:
composer install
or alternatively--on Windows--you can right-click on the composer.json and selectComposer Install
from the context menu.
For the cache, we will be needing Redis.
The installers can be found here:
- Linux version
http://redis.io/download - Windows version
https://github.com/MSOpenTech/redis/releases
Composer (this should already be done once you install through Composer)
Include this in the require section of your composer.json
:
"predis/predis-async": "dev-master"
For more information about this binding, you can check this link:
https://github.com/reactphp/zmq
Websockets are supported by Ratchet PHP from the server-side.
As for the WAMP sub-protocol having the publish/subscribe functionality, it can be supported by either Predis Pub/Sub or ZMQ.
The client-side WAMP is supported by Autobahn JS.
If you are to use ZMQ, you need to get the installer here:
Windows installer
You would also be needing to setup the PHP binding for ZMQ.
To download the PHP binding for ZMQ, you can find it in the following sites:
- http://zeromq.org/bindings:php
- https://github.com/Polycademy/php_zmq_binaries
- http://windows.php.net/downloads/pecl/releases/zmq/1.1.2/
To make life easier, you can just go to this link since this repository is the most active and recent one:
http://windows.php.net/downloads/pecl/releases/zmq/1.1.2/
- Download this file and extract it:
php_zmq-1.1.2-5.6-ts-vc11-x64.zip
- Copy
libzmq.dll
into your php directory (e.g. C:\wamp\bin\php\php5.3.8) - Copy the appropriate version of
php_zmq.dll
to your php extension directory (e.g. C:\wamp\bin\php\php5.3.8\ext) - Add the following line to your php.ini:
extension=php_zmq.dll
- Restart your web server to pickup the ini changes
Composer (this should already be done once you install through Composer)
Include this in the require section of your composer.json
:
"cboden/ratchet": "0.3.*",
"ext-zmq": "*",
"react/zmq": "0.4.*@dev"
For more information about binding React PHP to ZMQ, you can check this link:
https://github.com/reactphp/zmq
You can refer to the files found in the examples
directory to get an idea on how to use this.
Run the SQL script db/InitDatabase.sql
so you can also test the database access.
Your contribution to this project is most certainly welcomed. Feel free to fork this project and make it awesome.
This is an open source project under the MIT license. For more information, please refer to LICENSE.md