PHP code example of umer936 / cakephp-rabbitmq
1. Go to this page and download the library: Download umer936/cakephp-rabbitmq 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/ */
umer936 / cakephp-rabbitmq example snippets
$this->addPlugin('DevApp/RabbitMQ', [
'bootstrap' => true,
'path' => ROOT . DS . 'vendor' . DS . 'umer936' . DS . 'cakephp-rabbitmq' . DS,
]);
$this->addPlugin('DevApp/RabbitMQ', ['bootstrap' => true]);
'Gearman' => [
'Servers' => [
'127.0.0.1:4730'
],
'Jobs' => [
]
]
'Jobs' => [
'className' => 'Email'
]
'worker' => [
'className' => 'CvoTechnologies/Gearman.Worker',
'transport' => 'default',
'background' => true
]
$email = new Email('default');
$res = $email->from(['[email protected] ' => 'Your Site'])
->to('[email protected] ')
->subject('Testing cakephp-gearman built-in EmailTask')
->send('Your message');
namespace DevApp\RabbitMQ\Shell\Task;
use Cake\Console\Shell;
class SleepTask extends Shell
{
public function main($workload, GearmanJob $job)
{
$job->sendStatus(0, 3);
sleep($workload['timeout']);
$job->sendStatus(1, 3);
sleep($workload['timeout']);
$job->sendStatus(2, 3);
sleep($workload['timeout']);
return array(
'total_timeout' => $workload['timeout'] * 3
);
}
}