PHP code example of evilnet / queue-jobs-bundle

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

    

evilnet / queue-jobs-bundle example snippets




namespace Evilnet\QueueJobsBundle\ExampleJob;

use Evilnet\QueueJobsBundle\Dispatcher\DispatchableInterface;

class HelloWorld implements DispatchableInterface
{

    public $test_value;

    public function __construct()
    {
        $this->test_value = 'Hello from queue!';
    }

    public function execute(): bool
    {
        echo $this->test_value."\n";
        return true;
    }
}



namespace Evilnet\QueueJobsBundle\Command;

use Evilnet\QueueJobsBundle\Dispatcher\DispatcherInterface;
use Evilnet\QueueJobsBundle\ExampleJob\HelloWorld;

class ExampleService
{
    protected $dispatcher;

    public function __construct(DispatcherInterface $dispatcher)
    {
        $this->dispatcher = $dispatcher;
    }

    public function test()
    {
        $hello_world_job = new HelloWorld();
        $this->dispatcher->dispatch($hello_world_job, 'default'); //Queue name. You can use configured parameter here
    }
   
}