PHP code example of enl / amqp-workers
1. Go to this page and download the library: Download enl/amqp-workers 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/ */
enl / amqp-workers example snippets
$consumer = Consumer::factory($connection)
->withQueue(new Queue('consume_from'))
->withWorker($worker)
->run();
// Create AMQPConnection
$connection = new AMQPLazyConnection();
// We're using static `factory` function only for convenience with fluent interface
$consumer = Consumer::factory($connection)
// set queue definition. all parameters are default
->withQueue(new Queue('consume_from'))
// Worker is an object of WorkerInterface which handles given message body
->withWorker($worker)
// declare and start consuming the queue
->run();