Install the PHP dependencies using composer.
composer install
Create an initialization file rabbitmq.ini
which contains your RabbitMQ credentials. For example:
[rabbitmq]
HOST="localhost"
PORT=5672
USER="guest"
PASSWORD="guest"
VHOST="/"
A design constraint of this project was to isolate the database from the webserver. Instead of issuing SQL queries directly to the database, the webserver makes indirect requests through RabbitMQ.
Suppose that the database server provides a function login
that takes as parameters a username and password. The following code would access login
indirectly, just like calling any other function.
$db_client = new DatabaseRpcClient();
$db_client->call("login", $username, $password); // example
This design pattern is known as remote procedure calling (RPC). The files rpc_client.php
and rpc_server.php
were adapted from this official RabbitMQ tutorial.