Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Async Event Dispatcher Bundle Laravel Package

desarrolla2/async-event-dispatcher-bundle

View on GitHub
Deep Wiki
Context7

AsyncEventDispatcher

The AsyncEventDispatcherBundle means an asynchronous message management easy to implement in Symfony!

Installation

Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require desarrolla2/async-event-dispatcher-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Enable the Bundle

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Desarrolla2\AsyncEventDispatcherBundle\AsyncEventDispatcherBundle(),
        );

        // ...
    }

    // ...
}

Config the Bundle

You need put something like this in your config.yml

async_event_dispatcher:
  num_messages_per_execution: 1
  maximum_num_of_consumers: 4

Create your first message asynchronous

A controller that creates an example message would look like this:


<?php

namespace CoreBundle\Controller;

use CoreBundle\EventDispatcher\AsyncEvents;
use Desarrolla2\AsyncEventDispatcherBundle\Event\Event;

class MessageController extends AbstractController
{
    public function createAction()
    {
        $manager = $this->container->get('desarrolla2.async_event_dispatcher');
        $manager->dispatch(
            AsyncEvents::NAME_EVENT,
            new Event(['date' => (new \DateTime())->format('Ymd')])
        );
    }
}

The class that consumes our message would look like this

<?php

namespace CoreBundle\EventSubscriber;

use CoreBundle\EventDispatcher\AsyncEvents;
use Desarrolla2\AsyncEventDispatcherBundle\Event\Event;

class ExampleSubscriber extends AbstractEventSubscriber
{
    public static function getSubscribedEvents()
    {
        return [
            AsyncEvents::NAME_EVENT => 'onUpdateRequested',
        ];
    }

    public function onUpdateRequested(Event $event)
    {
        /* CODE */
    }
}

Configuration of the class that consumes our message:

services:
  _defaults: { public: true }

  core.event_subscriber.example_subscriber:
    class: 'CoreBundle\EventSubscriber\ExampleSubscriber'
    arguments:
      - '@service_container'
    tags:
      - { name: 'kernel.event_subscriber' }
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky