PHP code example of morningtrain / wp-queue
1. Go to this page and download the library: Download morningtrain/wp-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/ */
morningtrain / wp-queue example snippets
\Morningtrain\WP\Queue\Queue::registerWorker();
// Job/TestJob.php
use Morningtrain\WP\Queue\Abstracts\AbstractJob;
class TestJob extends AbstractJob {
public static function handle(mixed $args) : mixed
{
// Do something
return 'testing...';
}
}
// Another file
TestJob::dispatch('test_arg');
\Morningtrain\WP\Queue\Classes\Worker::getWorker('job_queue')->createJob($callback, $args);