Download the PHP package mortogo321/laravel-notify without Composer
On this page you can find all versions of the php package mortogo321/laravel-notify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mortogo321/laravel-notify
More information about mortogo321/laravel-notify
Files in mortogo321/laravel-notify
Package laravel-notify
Short Description A Laravel package for sending notifications and alerts to multiple providers
License MIT
Informations about the package laravel-notify
Laravel Notify
A flexible Laravel package for sending notifications and alerts to multiple providers including Slack, Discord, Telegram, LINE Notify, and Email.
Features
- Multiple Providers: Support for Slack, Discord, Telegram, LINE Notify, and Email notifications
- Easy Provider Switching: Seamlessly switch between providers with a simple API
- Send to Multiple Providers: Broadcast notifications to multiple providers at once
- Channel/Group Helpers: Built-in methods to list channels, get chat IDs, and more
- Highly Configurable: Customize each provider with extensive options
- Extensible Architecture: Easily add custom notification providers
- Facade Support: Clean and intuitive facade for easy integration
- Type-Safe: Built with modern PHP 8.2+ strict types
Requirements
- PHP 8.2, 8.3, or 8.4
- Laravel 11.x or 12.x
Installation
Install the package via Composer:
Publish the configuration file:
Configuration
Add your notification provider credentials to your .env file:
Getting Provider Credentials
Slack: Get your webhook URL from https://api.slack.com/apps (Incoming Webhooks)
Discord: Server Settings > Integrations > Webhooks > New Webhook
Telegram: Message @BotFather on Telegram, create a bot, then use the helper methods below to get your chat ID
LINE Notify: Generate a personal access token at https://notify-bot.line.me/my/
Email: Uses Laravel's built-in mail system (configure in config/mail.php)
Usage
Basic Usage
Using the default provider:
Using Specific Provider
Send to Multiple Providers
Provider Management
Channel & Group ID Helpers
Each provider includes helper methods to retrieve channel IDs, group IDs, and other useful information.
Slack Helpers
Discord Helpers
Telegram Helpers
LINE Notify Helpers
Email Helpers
Advanced Options
Slack with Attachments
Slack with Block Kit
Discord with Embeds
Telegram with Custom Options
LINE Notify with Sticker
LINE Notify with Image
Email with CC/BCC
Using in Controllers
Using in Jobs
Custom Providers
You can extend the package with custom providers:
Helper Functions
You can create a helper function in your app/helpers.php:
API Reference
NotifyManager Methods
| Method | Description |
|---|---|
provider(?string $name) |
Get a specific provider instance |
send(string $message, array $options = []) |
Send using default provider |
sendToMultiple(array $providers, string $message, array $options = []) |
Send to multiple providers |
extend(string $name, NotificationProvider $provider) |
Register a custom provider |
getProviders() |
Get list of registered provider names |
hasProvider(string $name) |
Check if provider is registered |
getDefaultProvider() |
Get the default provider name |
setDefaultProvider(string $name) |
Set the default provider |
getConfig(?string $key, mixed $default = null) |
Get configuration value(s) |
Provider Methods
All providers implement these methods:
| Method | Description |
|---|---|
send(string $message, array $options = []) |
Send notification |
getName() |
Get provider name |
isEnabled() |
Check if provider is enabled |
getAllConfig() |
Get all configuration values |
Provider-Specific Helpers
Slack
| Method | Description |
|---|---|
getChannel() |
Get configured channel |
getUsername() |
Get configured username |
getIconEmoji() |
Get configured icon emoji |
getWebhookUrl() |
Get masked webhook URL |
listChannels(string $botToken, array $options = []) |
List available channels |
getChannelInfo(string $botToken, string $channelId) |
Get channel info |
Discord
| Method | Description |
|---|---|
getUsername() |
Get configured username |
getAvatarUrl() |
Get configured avatar URL |
getWebhookUrl() |
Get masked webhook URL |
getWebhookId() |
Extract webhook ID from URL |
getWebhookInfo() |
Get webhook details from Discord |
getChannelId() |
Get channel ID from webhook |
getGuildId() |
Get guild (server) ID from webhook |
listGuildChannels(string $botToken, string $guildId) |
List guild channels |
Telegram
| Method | Description |
|---|---|
getChatId() |
Get configured chat ID |
getBotToken() |
Get masked bot token |
getParseMode() |
Get configured parse mode |
getMe() |
Get bot information |
getChat(?string $chatId) |
Get chat information |
getUpdates(array $options = []) |
Get updates with chat IDs |
getChatAdministrators(?string $chatId) |
Get chat administrators |
getChatMemberCount(?string $chatId) |
Get chat member count |
setWebhook(string $url, array $options = []) |
Set webhook URL |
deleteWebhook() |
Delete webhook |
getWebhookInfo() |
Get webhook info |
LINE Notify
| Method | Description |
|---|---|
getAccessToken() |
Get masked access token |
getStatus() |
Get LINE Notify API status |
| Method | Description |
|---|---|
getTo() |
Get configured recipient(s) |
getFrom() |
Get configured sender |
getFromName() |
Get configured sender name |
getSubject() |
Get configured subject |
getCc() |
Get configured CC recipients |
getBcc() |
Get configured BCC recipients |
validateEmail(string $email) |
Validate an email address |
validateEmails(array $emails) |
Validate multiple emails |
Upgrading
From v1.x to v2.0
- PHP 8.2+ required: Update your PHP version if running 8.1
- Laravel 11+ required: Update Laravel if running 10.x
- Guzzle removed: If you relied on
$this->client(Guzzle Client) in custom providers, switch to$this->post()and$this->get()helpers or use theHttpfacade directly - New
get()helper:AbstractProvidernow provides aget()method for HTTP GET requests
Testing
Run the test suite:
Run code quality checks:
Roadmap
The following features are planned for future releases:
- Queue Support: Send notifications asynchronously
- Schedule Support: Schedule recurring notifications
- Additional Providers: SMS (Twilio), Microsoft Teams, PagerDuty, Webhook
- Retry Logic: Automatic retry with exponential backoff
- Event System: Listen to notification events
- Rate Limiting: Built-in rate limiting per provider
- Notification Templates: Reusable message templates
Troubleshooting
Notification not sending
- Verify your provider credentials in
.env - Check that the provider is enabled (
NOTIFY_*_ENABLED=true) - Ensure the webhook URL or API credentials are correct
- Check logs for detailed error messages
Provider not found error
- Ensure the provider is configured in
config/notify.php - Verify the provider name matches exactly (e.g., 'slack', not 'Slack')
- Check that a default provider is set if not specifying one
Getting Telegram Chat ID
- Create a bot via @BotFather
- Add the bot to your group/channel
- Send a message to the group
- Use the helper:
Notify::provider('telegram')->getUpdates() - Find your chat ID in the
chatsarray
Getting LINE Notify Token
- Go to https://notify-bot.line.me/my/
- Click "Generate token"
- Select a chat room to receive notifications
- Copy the generated token to your
.envfile
Security
- Never expose webhook URLs or API tokens in client-side code
- Store all credentials in
.envfile (never commit to version control) - Use environment-specific credentials for different environments
- Helper methods return masked tokens/URLs for safe logging
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
MIT License. Please see License File for more information.
Credits
- Mor
- All contributors
Support
For issues, questions, or contributions, please visit the GitHub repository.
All versions of laravel-notify with dependencies
illuminate/http Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0