waltertamboer / communicator
A PHP library that helps communicating by broadcasting your messages to one or multiple channels.
Requires
- php: ^7.1
Requires (Dev)
- laminas/laminas-mail: ^2.10
- laminas/laminas-view: ^2.11
- phpmailer/phpmailer: ^5.2
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.0
- swiftmailer/swiftmailer: ^6.0
Suggests
- laminas/laminas-mail: To send e-mails using Laminas\Mail.
- laminas/laminas-view: To render e-mails using Laminas\View.
- phpmailer/phpmailer: To send e-mails using PHPMailer.
- swiftmailer/swiftmailer: To send e-mails using SwiftMailer.
This package is auto-updated.
Last update: 2024-10-26 09:53:01 UTC
README
Communicator is a PHP library that helps you broadcast messages over multiple channels. This can be useful when you want to send notifcations to users via multiple transports such as e-mail, SMS or IRC.
Install
Via Composer
$ composer require waltertamboer/communicator
Usage
Since communicator doesn't know where to send messages to, you need to implement
the Communicator\Recipient\RecipientInterface
interface. Communicator will use
it to determine the target addresses.
$recipient = new ... // An implementation of Communicator\Recipient\RecipientInterface $communicator = new Communicator\Communicator(); // Bind a transport. Of course this can be any transport you require. // It's also possible to bind multiple transports to the same channel. $communicator->bindTransport('my-channel', new Communicator\Transport\Noop\Transport()); // Now broadcast a message to all transports. $communicator->broadcast( [ $recipient, ], 'my-channel', [ 'my-param' => 'some param', ] );
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Install the dependencies via Docker:
docker run --rm --interactive --tty \ --volume $PWD:/app \ --volume $SSH_AUTH_SOCK:/ssh-auth.sock \ --volume /etc/passwd:/etc/passwd:ro \ --volume /etc/group:/etc/group:ro \ --user $(id -u):$(id -g) \ --env SSH_AUTH_SOCK=/ssh-auth.sock \ composer install
Run the unit tests:
Just make sure the unit tests are present :-)
Credits
License
The MIT License (MIT). Please see License File for more information.