PHP code example of symfony-bundles / event-queue-bundle

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

    

symfony-bundles / event-queue-bundle example snippets

 php
public function registerBundles()
{
    $bundles = [
        // ...
        new SymfonyBundles\EventQueueBundle\SymfonyBundlesEventQueueBundle(),
        // ...
    ];
    ...
}
 php
namespace AppBundle\Event;

use SymfonyBundles\EventQueueBundle\Event;

class MyEvent extends Event
{
    const NAME = 'event.example';

    private $time;
    private $message;

    public function __construct($time, $message)
    {
        $this->time = $time;
        $this->message = $message;
    }

    public function getTime()
    {
        return $this->time;
    }

    public function getMessage()
    {
        return $this->message;
    }
}
 php
namespace AppBundle\EventListener;

use AppBundle\Event\MyEvent;

class MyListener
{
    public function onEventExample(MyEvent $event)
    {
        $event->getTime();
        $event->getMessage();

        // and we are doing something...
    }
}
 php
while ($dispatcher->count()) {
    $dispatcher->dispatch();
}
 php
$dispatcher->setName('email.notifications');

while ($dispatcher->count()) {
    $dispatcher->dispatch();
}