Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/desarrolla2/async-event-dispatcher-bundle
https://github.com/desarrolla2/async-event-dispatcher-bundle
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/desarrolla2/async-event-dispatcher-bundle
- Owner: desarrolla2
- Created: 2019-09-25T08:05:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-21T10:11:36.000Z (over 3 years ago)
- Last Synced: 2024-11-11T11:12:46.318Z (about 2 months ago)
- Language: PHP
- Size: 66.4 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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:```bash
$ 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:```php
// 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
```yaml
async_event_dispatcher:
num_messages_per_execution: 1
maximum_num_of_consumers: 4
```
## Create your first message asynchronousA controller that creates an example message would look like this:
```php
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
'onUpdateRequested',
];
}public function onUpdateRequested(Event $event)
{
/* CODE */
}
}
```Configuration of the class that consumes our message:
```yaml
services:
_defaults: { public: true }core.event_subscriber.example_subscriber:
class: 'CoreBundle\EventSubscriber\ExampleSubscriber'
arguments:
- '@service_container'
tags:
- { name: 'kernel.event_subscriber' }
```