gupalo / browser-notifier
为浏览器扩展的 Symfony Notifier
1.3.0
2024-01-26 18:15 UTC
Requires
- psr/log: >=1.1
- symfony/notifier: ^5.4|^6.0|^7.0
- twig/twig: ^3.3
Requires (Dev)
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^10.0
README
简单使用 Symfony Notifier。
安装
Composer
composer require gupalo/browser-notifier
创建 config/packages/browser_notifier.yaml
imports:
- {resource: '../../vendor/gupalo/browser-notifier/config/services.yaml'}
使用方法
控制器
public function ...(..., BrowserNotifier $notifier): Response
{
...
$notifier->send('Something');
$notifier->success('Something');
$notifier->warning('Something');
$notifier->error('Something');
...
}
Twig
{{ app.request.hasPreviousSession ? app.flashes('notification')|browser_notifications|raw : '' }}
使用 BrowserLogger
作为实现 LoggerInterface
的日志记录器。