PHP code example of driade / queuebeam-laravel
1. Go to this page and download the library: Download driade/queuebeam-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/ */
driade / queuebeam-laravel example snippets
use Driade\Queuebeam\Facades\Queuebeam;
$result = Queuebeam::http()
->post('https://example.com/orders', ['order_id' => 8472])
->metas(['order_id' => 8472])
->idempotencyKey('order-8472')
->dispatch();
$result = Queuebeam::email()
->to('[email protected] ')
->to('[email protected] ')
->cc('[email protected] ')
->cc(['[email protected] ', '[email protected] '])
->bcc('[email protected] ')
->subject('Order sent')
->html('<p>Your order is on its way.</p>')
->dispatch(throws: false);
$result = Queuebeam::slack()
->destination('operations')
->message('Order blocked')
->dispatch();
$result = Queuebeam::discord()
->destination('engineering')
->message('Deployment failed')
->dispatch();
$result = Queuebeam::teams()
->destination('operations')
->message('Queue backlog exceeded 1,000 jobs')
->delay(new DateInterval('PT5M'))
->dispatch();
$result = Queuebeam::googleChat()
->destination('incidents')
->message('Payment provider is degraded')
->retries(5)
->dispatch();
Queuebeam::discord()
->webhookUrl('https://discord.com/api/webhooks/...')
->message('Hello from Queuebeam')
->dispatch();
Queuebeam::webhook('smoke.test')
->destination('webhook')
->payload(['source' => 'queuebeam-demo'])
->dispatch();
use Driade\Queuebeam\Facades\Queuebeam;
use Illuminate\Support\Str;
use RuntimeException;
$result = Queuebeam::slack()
->destination('smoke-slack')
->message('Queuebeam smoke test')
->metas(['suite' => 'providers', 'run_id' => (string) Str::uuid()])
->dispatch();
$operation = Queuebeam::waitForOperation(
$result->operation_id,
timeout_ms: 30_000,
poll_interval_ms: 500,
);
if ($operation->status !== 'succeeded') {
throw new RuntimeException("Delivery ended as {$operation->status}");
}
$page = Queuebeam::operations(status: 'dead_letter', type: 'email', limit: 50);
foreach ($page->operations as $operation) {
// $operation->operation_id, status, response_status and attempt_history
}
$next_page = $page->next_cursor === null
? null
: Queuebeam::operations(status: 'dead_letter', type: 'email', limit: 50, cursor: $page->next_cursor);
return [
'base_url' => env('QUEUEBEAM_URL', 'https://api.queuebeam.cloud'),
'api_key' => env('QUEUEBEAM_API_KEY'),
'throws' => env('QUEUEBEAM_THROWS', true),
'timeout_ms' => (int) env('QUEUEBEAM_TIMEOUT_MS', 3000),
'attempts' => (int) env('QUEUEBEAM_ATTEMPTS', 3),
];
Queuebeam::configure(timeout_ms: 5000, attempts: 5);