devnullius / yii2-queue-addon
Addon for yii2-queue original extension
Installs: 5 970
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.4.0 < 8.4
- yiisoft/yii2: ~2.0.37
- yiisoft/yii2-queue: ^2.3
Requires (Dev)
- roave/security-advisories: dev-latest
README
Addon for yii2-queue original extension for multi channel version documentation not prepared yet! multichannel version is since v3xx
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist devnullius/yii2-queue-addon "^1.0"
or add
"devnullius/yii2-queue-addon": "^1.0"
to the "require" section of your composer.json
file.
However, note that yii2-queue extension must be configured and running.
Configs
Add SetUp bootstrap class to common main.php in bootstrap section after "queue".
use devnullius\queue\addon\bootstrap\SetUp as QueueAddonSetUp; 'bootstrap' => [ 'queue', QueueAddonSetUp::class ]
For binding events with listeners use following style in your bootstrap.(Or something like that;-)
use devnullius\queue\addon\dispatchers\SimpleEventDispatcher; use yii\di\Container; use devnullius\queue\addon\example\TestExampleEvent; use devnullius\queue\addon\example\TestExampleListener; $container->setSingleton(SimpleEventDispatcher::class, static function (Container $container) { return new SimpleEventDispatcher($container, [ TestExampleEvent::class => [TestExampleListener::class], ]); });
Usage
Once the extension installed, simply you can take a look on examples inside, running them in your framework environment. Something like this.
use devnullius\queue\addon\example\TestEventService; $testService = Yii::createObject(TestEventService::class); $testService->testEvent('Event generation no ... ');
After that, you can run queue/listen, in --verbose mode, to see how listener/handler work.
php yii queue/listen --verbose