PHP code example of maksimdimitrov / mdim-amqp-laravel

1. Go to this page and download the library: Download maksimdimitrov/mdim-amqp-laravel 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/ */

    

maksimdimitrov / mdim-amqp-laravel example snippets

 artisan vendor:publish --tag=mdim_rabbitmq-config
 artisan
 artisan mdim_rabbitmq:start_consumer 'MdimAMQPLaravel\Examples\HelloJob'
 artisan mdim_rabbitmq:publish_hello
 artisan mdim_rabbitmq:start_consumer 'SomeNamespace\SomeClass'


namespace SomeNamespace;
use MdimAMQPLaravel\ReceiveJob;

class SomeClass extends ReceiveJob
{
    public function handle()
    {
        echo 'message -> ' . $this->msg->body . PHP_EOL;
        $this->msg->delivery_info['channel']->basic_ack($this->msg->delivery_info['delivery_tag']);
    }
    
    public static function getConnectionName()
    {
        return 'default'; // default is the connection name from config file, e.g. default or some-other-rabbitmq-service
    }
    
    public static function getQueueName()
    {
        return 'some-queue-name';
    }
    
    public static function getConsumerTag() 
    {
        return '';
    }
}