PHP code example of slm / queue-doctrine
1. Go to this page and download the library: Download slm/queue-doctrine 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/ */
slm / queue-doctrine example snippets
return [
'doctrine' => [
'connection' => [
// default connection name
'orm_default' => [
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => [
'host' => 'localhost',
'port' => '3306',
'user' => 'username',
'password' => 'password',
'dbname' => 'database',
]
]
]
],
];
return [
'slm_queue' => [
'queue_manager' => [
'factories' => [
'foo' => 'SlmQueueDoctrine\Factory\DoctrineQueueFactory'
]
]
]
];
return [
'slm_queue' => [
'job_manager' => [
'factories' => [
'My\Job' => 'My\JobFactory'
]
]
]
];
return [
'slm_queue' => [
'queues' => [
'foo' => [
// ...
]
]
]
];
// scheduled for execution asap
$queue->push($job);
// will get executed before jobs that have higher priority
$queue->push($job, [
'priority' => 200,
]);
// scheduled for execution 2015-01-01 00:00:00 (system timezone applies)
$queue->push($job, [
'scheduled' => 1420070400,
]);
// scheduled for execution 2015-01-01 00:00:00 (system timezone applies)
$queue->push($job, [
'scheduled' => '2015-01-01 00:00:00'
]);
// scheduled for execution at 2015-01-01 01:00:00
$queue->push($job, [
'scheduled' => '2015-01-01 00:00:00',
'delay' => 3600
]);
// scheduled for execution at now + 300 seconds
$queue->push($job, [
'delay' => 'PT300S'
]);
// scheduled for execution at now + 2 weeks (1209600 seconds)
$queue->push($job, [
'delay' => '2 weeks'
]);
// scheduled for execution at now + 300 seconds
$queue->push($job, [
'delay' => new DateInterval("PT300S"))
]);