Updated on 20 Sep 2023

I am going to use the stomp-php library from packagist.

require __DIR__ . '/vendor/autoload.php';

use Stomp\Client;
use Stomp\SimpleStomp;
use Stomp\Transport\Bytes;
use Stomp\Transport\Message;

// make a connection
$client = new Client('tcp://localhost:61613');
$client->setLogin('demo_user', 'demo_pass');
$stomp = new SimpleStomp($client);

// send a message to the queue
$stomp->send('/queue/q1', new Message('test message from php 2' . "\n"));

Sending the message

This is how I sent the message using the command line.

php send.php


I can use rabbitmqadmin to check the message

rabbitmqadmin list vhosts

And to see the message, I can use the following command.

rabbitmqadmin get queue=q1 --vhost=demo_host -u guest -p guest

I am using guest username because I have assigned the appropriate privileges to that account.