PHP

Stomp client for PHP

Overview

[PHP Stomp client|http://code.google.com/p/stompcli/ that supports various connection methods and mechanisms for transforming messages to suitable formats. Check documentation for complete feature list.

Download

Download the current release from http://code.google.com/p/stompcli/downloads/list

Quick Start

After you download the archive, extract it to your include_path. Once you've done that, you can use the client as follows

<?php
// include a library
require_once("Stomp.php");
// make a connection
$con = new Stomp("tcp://localhost:61613");
// connect
$con->connect();
// send a message to the queue
$con->send("/queue/test", "test");
// subscribe to the queue
$con->subscribe("/queue/test");
// receive a message from the queue
$msg = $con->readFrame();

// do what you want with the message
if ( $msg->body === "test") {
    echo "Worked\n";
    // mark the message as received in the queue
    $con->ack($msg);
} else {
    echo "Failed\n";
}

// disconnect
$con->disconnect();

Documentation

Developers

Source

Use this command to anonymously check out the latest project source code:

svn checkout http://stompcli.googlecode.com/svn/trunk/ stompcli-read-only

Developer Mailing List

http://groups.google.com/group/stompcli-dev

Issues

http://code.google.com/p/stompcli/issues/list

Unit Testing

Instructions on how to set up a unit testing environment could be found here

See Also

Labels

php php Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 30, 2007

    larry h. says:

    The test page for the php client, Test.php, lacks feedback. Here is a version w...

    The test page for the php client, Test.php, lacks feedback. Here is a version with more description of what is going right and wrong:

     <?php
    
     try {
    	require_once 'Stomp.php';
    
    	echo 'Creating StompConnection object... <br />';
    	$c = new StompConnection("127.0.0.1");  // requires Socket extension
    	echo 'Connecting with user/pass... <br />';
    	$result = $c->connect("hiram", "test");
    	print_r($result);
    
    	echo '<br />Subscribing... <br />';
    	$c->subscribe("/queue/FOO");
    	echo 'Sending message... <br />';
    	$c->send("/queue/FOO", "Hello World!");
    
    	// Wait for the message to come in..
    	echo 'Waiting for incoming message... <br />';
    	$result = $c->readFrame();
    	print_r($result);
    
    	$c->disconnect();
    
    	echo '<br />Finished';
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    
    ?>
    
    
    
  2. Nov 30, 2007

    larry h. says:

    The script Stomp.php requires the 'socket' extension (it was not on my Windows i...

    The script Stomp.php requires the 'socket' extension (it was not on my Windows install). Add that extension if you cannot get past

        socket_create()
    
  3. Nov 30, 2007

    larry h. says:

    The issue tracker appears to be misdirecting to iona.com, so I'll add this here ...

    The issue tracker appears to be misdirecting to iona.com, so I'll add this here for now:  There are deprecations in Stomp.php     

    Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of socket_recv(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal\Stomp.php on line 156

    Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of socket_recv(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal\Stomp.php on line 175

    Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of socket_recv(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal\Stomp.php on line 185

  4. Dec 10, 2007

    larry h. says:

    To fix the warnings above, change Stomp.php, removing the ampersand on the $b (b...

    To fix the warnings above, change Stomp.php, removing the ampersand on the $b (buffer) arg in those lines. In other words, go from

            $rc = socket_recv($this->socket, &$b, 1, 0);
    

     to

            $rc = socket_recv($this->socket, $b, 1, 0);