1. Go to this page and download the library: Download dotkernel/dot-queue 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/ */
dotkernel / dot-queue example snippets
return [
'dot_queue' => [
'default_queue' => '{{QUEUE_NAME}}',
'failed_job_provider' => [
// these options are specific to the provider used
// we give here the database failed job provider options
'db_adapter' => 'database',
'table' => 'failed_jobs',
],
'adapter_manager' => [],
'adapters' => [
'database' => [
'type' => \Dot\Queue\Adapter\DatabaseAdapter::class,
'options' => [
// configured zend db service name adapter
'db_adapter' => 'database',
'table' => 'jobs',
'failed_table' => 'failed_jobs'
],
// other adapters...
]
],
'queue_manager' => [],
'queues' => [
'{{QUEUE_NAME}}' => [
// this is the default queue type, if not specified
// 'type' => \Dot\Queue\Queue\PersistentQueue::class,
'options' => [
'adapter' => 'database',
// after how many seconds, failed job will be attempted again
'retry_after' => 60,
// maybe other queue options later
]
],
// other queues...
]
]
];
//...
class MyJob extends AbstractJob
{
public function process()
{
//...
}
public function failed($e)
{
//...
}
}
$job = $queueManager->createJob(MyJob::class)
->setMaxAttempts(3)
->setTimeout(30)
->setDelay(0)
->setPriority(1);
// set custom data into the job, that you can access when the job will be processed
$job->set('key1', 'some data')
->set('key2', 'some other data');
// dispatch the job
$job->dispatch(); //to the default queue OR
$job->dispatch('queue_name');
bash
$ php dot queue:consume
bash
$ php dot help queue:consume
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.