Download the PHP package teaminfinitydev/laravel-activity-log-discord without Composer
On this page you can find all versions of the php package teaminfinitydev/laravel-activity-log-discord. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teaminfinitydev/laravel-activity-log-discord
More information about teaminfinitydev/laravel-activity-log-discord
Files in teaminfinitydev/laravel-activity-log-discord
Package laravel-activity-log-discord
Short Description Laravel package for activity logging with Discord webhook integration
License MIT
Informations about the package laravel-activity-log-discord
Laravel Activity Log Discord
A powerful Laravel package that logs user activities and system events, then sends beautiful notifications to Discord channels via webhooks. Perfect for monitoring your application's important events in real-time.
๐ Features
- ๐ Comprehensive Activity Logging - Track user actions, model changes, and custom events
- ๐ฏ Discord Integration - Send rich embed notifications to Discord channels
- ๐ Queue Support - Asynchronous processing for better performance
- ๐จ Customizable Embeds - Configurable colors, icons, and formatting
- ๐ง Easy Configuration - Environment-based settings with sensible defaults
- ๐ Database Storage - Store activity logs with full relationship tracking
- ๐ท๏ธ Auto-Model Tracking - Simple trait-based automatic logging
- ๐ Event Filtering - Enable/disable specific event types
- โก Performance Optimized - Efficient database queries and caching
- ๐งช Test Webhook - Built-in webhook testing functionality
- ๐ Bootup Messages - Optional application startup notifications
- ๐ก๏ธ Error Handling - Robust error handling and logging
- ๐ Security - Automatic sensitive data masking
๐ Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
- GuzzleHTTP 7.0 or higher
๐ Installation
Install the package via Composer:
Publish the configuration file:
Publish and run the migrations:
โ๏ธ Configuration
Discord Webhook Setup
- Go to your Discord server settings
- Navigate to Integrations โ Webhooks
- Create a new webhook for your desired channel
- Copy the webhook URL
Environment Configuration
Add the following to your .env file:
SSL Configuration
By default, this package uses SSL verification when connecting to Discord webhooks. This is recommended for production environments.
For Production Environments (Default):
The package uses the following Guzzle configuration by default, which includes SSL verification:
For Local Development or Troubleshooting:
If you're having connection issues in a local development environment or behind certain corporate firewalls, you may need to disable SSL verification temporarily:
- Open
src/Services/DiscordWebhookService.php - Find the client initialization in the constructor
- Change the
verifyoption tofalse:
โ ๏ธ IMPORTANT SECURITY WARNING: Only disable SSL verification in local development environments. Never disable SSL verification in production as it makes your application vulnerable to man-in-the-middle attacks.
Test Your Integration
After configuration, test your webhook integration:
๐ Usage
Basic Usage
Manual Logging
Built-in Helper Methods
Automatic Model Tracking
Add the LogsActivity trait to your models for automatic tracking:
User Authentication Logging
Track user login/logout events automatically:
Application Bootup Monitoring
Enable bootup messages to monitor when your application starts:
This will send a message to Discord whenever your web application boots up, useful for monitoring deployments and server restarts.
๐งช Troubleshooting
Connection Issues
If you're experiencing issues connecting to Discord webhooks, try the following solutions:
1. Check Your Webhook URL
Ensure your Discord webhook URL is correctly formatted and valid. It should look like:
2. SSL Certificate Issues
If you receive a "No response from Discord (connection error)" error, you might be having SSL certificate issues, especially in a local development environment.
Temporary Fix (Development Only):
Modify the DiscordWebhookService.php file to disable SSL verification:
โ ๏ธ WARNING: Re-enable SSL verification (verify => true) before deploying to production!
3. Firewall or Network Issues
- Ensure your server/local environment can access external services
- Check if your firewall allows outgoing connections to Discord (ports 443/80)
- Try testing with a different internet connection
4. Detailed Debug Logging
Enable detailed logging to see what's happening with the connection:
Then check your Laravel logs for more information.
๐จ Discord Message Examples
The package sends rich embed messages to Discord that look like this:
User Login Event
Application Bootup Event
Model Created Event
๐ Database Schema
The package creates an activity_logs table with the following structure:
| Column | Type | Description |
|---|---|---|
id |
bigint | Primary key |
event_type |
string | Type of event (e.g., 'user.login') |
description |
text | Human-readable description |
subject_type |
string | Model class of the subject |
subject_id |
bigint | ID of the subject model |
causer_type |
string | Model class of the causer |
causer_id |
bigint | ID of the causer model |
properties |
json | Additional event data |
discord_sent |
boolean | Whether sent to Discord |
discord_sent_at |
timestamp | When sent to Discord |
created_at |
timestamp | When the log was created |
updated_at |
timestamp | When the log was updated |
๐ง Customization
Custom Event Colors and Icons
Modify config/activity-log-discord.php to customize event appearance:
Queue Configuration
For high-traffic applications, enable queue processing:
Don't forget to run your queue workers:
๐ License
The MIT License (MIT). Please see License File for more information.