PHP code example of so-php / rpc

1. Go to this page and download the library: Download so-php/rpc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

so-php / rpc example snippets


$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$ch = $conn->channel();

$server = new Server($ch);
$server->serve(function($name){ return "Hello $name"; }, 'greet');
// or more commonly:
// $rpc->serve(new Greeter()); // where greeter has a greet method.

echo "listening for RPCs @ " . $server->getQueueName();
while(true){
    $server->wait();
}