mikaelkael / ntfy-notifier
Symfony Ntfy Notifier Bridge
Installs: 140
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-notifier-bridge
Requires
- php: >=7.4
- ext-json: *
- symfony/framework-bundle: ^5.4|^6.0
- symfony/http-client: ^5.0|^6.0
- symfony/notifier: ^5.4|^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ~8.5|~9.5
- vimeo/psalm: ^4.29
README
Provides Ntfy integration for Symfony Notifier. The component should be introduced in Symfony 6.4 with this PR #50131. This bundle provides same functionalities for Symfony 5.4.x to 6.3.x.
DSN example
# .env
NTFY_DSN=ntfy://[USER:PASSWORD]@default[:PORT]/TOPIC?[secureHttp=[on]]
where:
URL
is the ntfy server which you are using- if
default
is provided, this will default to the public ntfy server hosted on ntfy.sh.
- if
TOPIC
is the topic on this ntfy server.PORT
is an optional specific port.USER
andPASSWORD
are username and password in case of access control supported by the server
In case of a non-secure server, you can disable https by setting secureHttp=off
.
Enable texter
# config/packages/notifier.yaml
framework:
notifier:
texter_transports:
nfty: '%env(NTFY_DSN)%'
Send push message
// src/Controller/TestController.php
namespace App\Controller;
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\TexterInterface;
use Symfony\Component\Routing\Annotation\Route;
class TestController
{
/**
* @Route("/test")
*/
public function test(TexterInterface $texter)
{
$pushMessage = new PushMessage(
'Title',
'Message content',
new NtfyOptions(['tags' => ['warning'], 'priority' => 5])
);
$result = $texter->send($pushMessage);
// ...
}
}