webmaster-hm / laravel-notify81
v1.0.5
2024-01-02 12:22 UTC
Requires
- php: ^7.2|^8.0|^8.1
- laravel/framework: ^10.0
- monolog/monolog: ^3.0
- psr/log: ^1.0
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.0.0
- mockery/mockery: ~1.3.3|^1.4.2
- php-http/guzzle7-adapter: ^1.0.0
- phpunit/phpunit: ^8.4|^9.3.3
- sentry/sentry-laravel: ^3.1.2
- symfony/options-resolver: ^5.1
Suggests
- sentry/sentry: Required to use the Sentry driver (~3.0).
README
Laravel Notify 是一个 Laravel 5 包,允许您向各种服务发送通知消息。
当前通过 Monolog 支持的通知通道
- 电子邮件
- Pushover
- Slack
- Fleephook
- Flowdock
- Plivo SMS 消息服务。
- Twilio SMS 消息服务。
- Sentry 通过 Sentry SDK for PHP
- Mailgun
版本兼容性
安装
2.x 版本使用 Package Discovery。如果您使用的是 1.x 版本,您需要按照这些 说明 操作。
通过 composer 安装 - 在终端中
composer require tylercd100/laravel-notify
然后您需要运行以下命令以复制配置文件。
php artisan vendor:publish --provider="Tylercd100\Notify\Providers\NotifyServiceProvider"
使用方法
在更改了您的配置文件(config/notify.php)后,您可以使用它如下所示
Notify::debug("This is a debug message!"); Notify::info("This is a info message!"); Notify::notice("This is a notice message!"); Notify::warning("This is a warning message!"); Notify::error("This is a error message!"); Notify::critical("This is a critical message!"); Notify::alert("This is a alert message!"); Notify::emergency("This is a emergency message!"); # Add context Notify::info("This is a info message with context!",['user'=>$user, 'data'=>$data]);
其他功能
Laravel Notify 还公开了额外的 Facades。要使用它们,您需要将它们添加到您的 config/app.php 文件中的别名数组中。
"Pushover" => Tylercd100\Notify\Facades\Pushover::class, "Flowdock" => Tylercd100\Notify\Facades\Flowdock::class, "FleepHook" => Tylercd100\Notify\Facades\FleepHook::class, "Slack" => Tylercd100\Notify\Facades\Slack::class, "Plivo" => Tylercd100\Notify\Facades\Plivo::class, "Twilio" => Tylercd100\Notify\Facades\Twilio::class, "Sentry" => Tylercd100\Notify\Facades\Sentry::class, "Mailgun" => Tylercd100\Notify\Facades\Mailgun::class,
然后您可以这样使用它们
Slack::info("This is information!"); Pushover::critical("Everything is broken and the server room caught fire!");