PHP code example of akimimi / mqutil

1. Go to this page and download the library: Download akimimi/mqutil 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/ */

    

akimimi / mqutil example snippets



use Akimimi\MessageQueueUtil\MessageQueueUtilTest;
use Akimimi\MessageQueueUtil\AliyunMnsClientConfig;
use Akimimi\MessageQueueUtil\Exception\MquException;

$config = new AliyunMnsClientConfig("endpoint", "access_id", "access_key");
$util = new MessageQueueUtil("queue_name", $config);

# Create a queue
$util->createQueue();

# Send text messages
$util->sendTextMessage("some plain text");

# Receive messages
try {
    $messageBody = $util->receiveMessage(30);
    if ($messageBody != null) {
      // do something with your business
    }
} catch (MquException $e) {
  // do something with the exception.
}