PHP code example of tomahawk / queue

1. Go to this page and download the library: Download tomahawk/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/ */

    

tomahawk / queue example snippets




use Tomahawk\Queue\Application;
use Tomahawk\Queue\Storage\StorageInterface;
use Tomahawk\Queue\Storage\RedisStorage;
use Predis\Client;
use Pimple\Container;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 * Get the Autoloader
 */
      'scheme' => 'tcp',
         'host'   => '10.0.0.1',
         'port'   => 6379,
    ]);
    return new RedisStorage($client);
};

$eventDispatcher = $container[EventDispatcherInterface::class];

// Add events
$eventDispatcher->addListener(\Tomahawk\Queue\JobEvents::PROCESSED, function(\Tomahawk\Queue\Event\PreProcessEvent $event) {
    // Log to a file
});

$container[EventDispatcherInterface::class];


  
 
 use Predis\Client;
 use Tomahawk\Queue\Manager;
 use Tomahawk\Queue\Storage\RedisStorage;
 
 $client = new Client([
      'scheme' => 'tcp',
      'host'   => '10.0.0.1',
      'port'   => 6379,
 ]);
 $storage = new RedisStorage($client);
     
 $manager = new Manager($storage);
 
 $arguments = [
     'email' => '...',
     'subject' => '...',
];
 
 $manager->queue('queue_email', 'JobClass', $arguments);