PHP code example of mpsaravanan / tail
1. Go to this page and download the library: Download mpsaravanan/tail 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/ */
mpsaravanan / tail example snippets
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
*/
//...
$app->configure('tail-settings');
$app->register(Mookofe\Tail\LumenServiceProvider::class);
//...
return array(
'default' => 'default_connection',
'connections' => array(
'default_connection' => array(
'host' => 'localhost',
'port' => 5672,
'username' => 'guest',
'password' => 'guest',
'vhost' => '/',
'exchange' => 'default_exchange_name',
'consumer_tag' => 'consumer',
),
'other_server' => array(
'host' => '192.168.0.10',
'port' => 5672,
'username' => 'guest',
'password' => 'guest',
'vhost' => '/',
'exchange' => 'default_exchange_name',
'consumer_tag' => 'consumer',
),
),
);
Tail::add('queue-name', 'message');
Tail::add('queue-name', 'message', array('connection_name' => 'connection_name_config_file'));
Tail::add('queue-name', 'message', array('exchange' => 'exchange_name'));
$options = array (
'connection_name' => 'connection_name_config_file',
'exchange' => 'exchange_name',
'vhost' => 'vhost',
'type' => 'type_name',
);
Tail::add('queue-name', 'message', $options);
$message = new Tail::createMessage;
$message->queue_name = 'queue-name';
$message->message = 'message';
$message->connection_name = 'connection_name_in_config_file';
$message->exchange = 'exchange_name';
$message->vhost = 'vhost';
$message->save();
Tail::listen('queue-name', function ($message) {
//Your message logic code
});
$options = array(
'message_limit' => 50,
'time' => 60,
'empty_queue_timeout' => 5,
'connection_name' => 'connection_name_in_config_file',
'exchange' => 'exchange_name',
'vhost' => 'vhost'
);
Tail::listenWithOptions('queue-name', $options, function ($message) {
//Your message logic code
});
$ php composer install
batch
$ php composer update
batch
'Tail' => 'Mookofe\Tail\Facades\Tail',