A library for communicating with CloudMQTT is phpMQTT.
Here are a code example which make use of phpMQTT.
The complete example can be found here: https://github.com/CloudMQTT/php-mqtt-example .
Another option is to use Mosquitto-PHP . Good examples can be found here https://github.com/mgdm/Mosquitto-PHP/tree/master/examples .