Download the PHP package osa-eg/laravel-teams-notification without Composer
On this page you can find all versions of the php package osa-eg/laravel-teams-notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download osa-eg/laravel-teams-notification
More information about osa-eg/laravel-teams-notification
Files in osa-eg/laravel-teams-notification
Package laravel-teams-notification
Short Description A Laravel package to send notifications to Microsoft Teams
License MIT
Informations about the package laravel-teams-notification
Laravel Teams Notification
Laravel Teams Notification is a package for sending notifications to Microsoft Teams using the "Post to a channel when a webhook request is received" workflow webhook. It supports sending normal messages, exception messages with trace, and messages with additional details or JSON blocks, following the JSON structure required by Microsoft Teams adaptive cards. The package also includes custom logging functionality for Laravel, making it easy to integrate with your existing Laravel applications and log important events directly to Microsoft Teams channels.
Table of Contents
- Features
- Installation
- Publishing Files
- Config
- Usage
- Sending a Normal Message
- Sending a Normal Message with Additional Details and Color
- Sending a Success Message
- Sending a Warning Message
- Sending an Error Message with Trace and Default Attention Color
- Sending a Message with Array as JSON Block and Custom Color
- Custom Logging
- Methods
- Learn More
- License
Features
- Send Normal Messages: Send simple text notifications to Teams.
- Send Messages with Additional Details: Include extra details in the notification.
- Send Success Messages: Highlight successful operations with a green color.
- Send Warning Messages: Indicate warnings with an orange color.
- Send Error Messages: Report errors with a red color and optional stack trace.
- Send Messages with JSON Blocks: Include formatted JSON data in the message.
- Custom Logging: Log messages directly to Microsoft Teams using Laravel’s logging system.
- Configurable Message Colors: Set custom colors for messages with predefined options.
Installation
To install the package, you need PHP 7.0 or higher and Laravel 5.5 or later. Use Composer:
Then, add your Microsoft Teams webhook URL to your .env
file:
Publishing Files
Config
To publish the config file included with this package to your Laravel project, run:
Usage
Sending a Normal Message
To send a normal message, use the sendMessage
method:
Sending a Normal Message with Additional Details and Color
To send a normal message with additional details, use the sendMessage
method with the second parameter:
Sending a Success Message
To send a success message, use the success
method:
Sending a Warning Message
To send a warning message, use the warning
method:
Sending an Error Message with Trace and Default Attention Color
To send an error message with trace, use the error
method and bindTrace
method:
Sending a Message with Array as JSON Block and Custom Color
To send a message with an array as a JSON block, use the sendJsonMessage
method:
Custom Logging
The package also supports custom logging to Microsoft Teams. To set up custom logging, follow these steps:
-
Configure Logging in Your Laravel Project:
In
config/logging.php
, add the following configuration: -
Use the Custom Log Channel:
To log messages to Teams, use the
teams
log channel:
Methods
- setColor(string $color): Sets the color of the message. Valid colors are "default", "dark", "light", "accent", "good", "warning", "attention".
- success(): Sets the message color to "good".
- warning(): Sets the message color to "warning".
- error(): Sets the message color to "attention".
- sendMessage($message, array $details = []): Sends a normal message with additional details.
- sendException(\Exception $exception): Sends an exception message with optional trace details.
- bindTrace(): Includes the trace in the exception message.
- sendJsonMessage($message, array $data): Sends a message with an array as a JSON block.
Learn More
For a detailed guide on integrating Microsoft Teams notifications with your Laravel application, check out my Medium article:
Streamlining Laravel Notifications with Microsoft Teams Workflow Integration
License
This package is open-sourced software licensed under the MIT license.
This README now includes a Table of Contents section that links to different parts of the document for easier navigation.
All versions of laravel-teams-notification with dependencies
illuminate/support Version ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
guzzlehttp/guzzle Version >=6.5
monolog/monolog Version >=1.0