PHP code example of edfa3ly-backend / rabbitmq-bundle-consumer-generator

1. Go to this page and download the library: Download edfa3ly-backend/rabbitmq-bundle-consumer-generator 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/ */

    

edfa3ly-backend / rabbitmq-bundle-consumer-generator example snippets


class ServiceExample
{  

    /** @var GeneratorWrapper $wrapper */
    protected $wrapper;
   
   /**
    * ServiceExample constructor.
    *
    * @param GeneratorWrapper $wrapper
    */
   public function __construct(
       GeneratorWrapper $wrapper
   ) {
       $this->wrapper         = $wrapper;
   }
   
   /**
    * @throws Exception
    */
   public function createConsumers()
   {
       $consumer = new ConsumerSkeleton() ;
       $consumer->setName('the name of your consumer');
       $consumer->setQueueRoutingKeys(['array of routing keys of your consumer']);
       $consumer->setExchangeType('fanout , direct , topic or headers');
       $consumer->setExchangeName('the name of your consumer's exchange');
       $consumer->setQueueName('Queue name');
       $consumer->setCallback('\path\to\your\consumer\callback::class');
       $consumer->setAmqpConsumerType('consumers or batch_consumers');
       
       $this->wrapper->writeConsumers( [$consumer], 'relative\path\to\your\consumers\yaml');
   }
}