job-runner / symfony-notifier-adapter
1.3.0
2024-05-08 09:10 UTC
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- job-runner/job-runner: ^1.3
- symfony/notifier: ^6.0 || ^7.0
Requires (Dev)
- doctrine/coding-standard: ^12.0
- phpunit/phpunit: ^10.5.19
- psalm/plugin-phpunit: ^0.19.0
- vimeo/psalm: ^5.24
This package is auto-updated.
Last update: 2024-09-20 11:52:27 UTC
README
此包为JobRunner提供了symfony/notifier适配器。
安装
composer require job-runner/symfony-notifier-adapter
使用
<?php declare(strict_types=1); use JobRunner\JobRunner\Job\CliJob; use JobRunner\JobRunner\Job\JobList; use JobRunner\JobRunner\CronJobRunner; use Symfony\Component\Notifier\Bridge\RocketChat\RocketChatTransport; use Symfony\Component\Notifier\Channel\ChatChannel; use Symfony\Component\Notifier\Notifier; use JobRunner\JobRunner\SymfonyNotifier\SymfonyNotifierEventListener; require 'vendor/autoload.php'; $rocket = new RocketChatTransport('mytoken', '#mychannel'); $rocket->setHost('chat.myhost.com'); $chat = new ChatChannel($rocket); $notifier = new Notifier(['chat' => $chat]); $jobCollection = new JobList(); $jobCollection->push(new CliJob('php ' . __DIR__ . '/tutu.php', '* * * * *')); CronJobRunner::create() ->withEventListener((new SymfonyNotifierEventListener($notifier))->withNotificationChannelFail(['chat'])) ->run($jobCollection);