To access CloudAMQP (or any RabbitMQ/AMQP server) from PHP php-amqplib is a good choice. The library php-amqplib was used for the PHP examples of RabbitMQ in Action and in the official RabbitMQ tutorials.

Code example Publish and Subscribe

The following code snippet show how to connect, publish and consume a message via CloudAMQP.

require('vendor/autoload.php');
define('AMQP_DEBUG', true);
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;

/**
* Create a connection to RabbitMQ
*/

$url = parse_url(getenv('CLOUDAMQP_URL'));
$conn = new AMQPConnection(
          $url['host'], //host - CloudAMQP_URL
          5672,         //port - port number of the service, 5672 is the default
          $url['user'], //user - username to connect to server
          $url['pass'], //password - password to connecto to the server
          substr($url['path'], 1) //vhost
);
$ch = $conn->channel();

$exchange = 'amq.direct';
$queue = 'basic_get_queue';
$ch->queue_declare(
          $queue, //queue name
          false,  //passive -  check whether an exchange exists without modifying server state
          true,   //durable - RabbitMQ will never lose the queue if a crash occurs
          false,  //exclusive - if queue only will be used by one connection
          false   //autodelete - queue is deleted when last consumer unsubscribes
);

$ch->exchange_declare($exchange, 'direct', true, true, false);
$ch->queue_bind($queue, $exchange);

$msg_body = 'the body';
$msg = new AMQPMessage($msg_body, array('content_type' => 'text/plain', 'delivery_mode' => 2));
$ch->basic_publish($msg, $exchange);

$retrived_msg = $ch->basic_get($queue);
var_dump($retrived_msg->body);
$ch->basic_ack($retrived_msg->delivery_info['delivery_tag']);

$ch->close();
$conn->close();

The full code example can be found at github.com/cloudamqp/php-amqplib-example.

Alternative clients

PECL AMQP
PECL AMQP library built on top of the RabbitMQ C client
amqphp
A complete AMQP protocol implementation and a set of libraries for writing AMQP producers and consumers.
Vorpal Bunny
Vorpal Bunny is an experimental rabbitmq-jsonrpc-channel PHP driver designed to allow expedited single call HTTP delivery for Basic.Deliver calls to RabbitMQ.