garcia1901l/laravel-activity-lite
Composer 安装命令:
composer require garcia1901l/laravel-activity-lite
包简介
Lightweight activity logger for Laravel
README 文档
README
Lightweight activity logger for Laravel using MongoDB (Laravel 10–12 compatible).
✨ Features
- 🚀 Automatic model activity tracking (create/update/delete)
- 🔍 MongoDB database for lightweight operation
- 👤 Tracks causer (user, artisan, queue jobs)
- ⚡ Configurable event logging
- 📊 Powerful querying capabilities
- 📦 Easy installation and setup
Requisitos de MongoDB
El paquete es compatible con estas versiones del driver oficial:
mongodb/laravel-mongodb: 3.8+ (incluye v4 y v5)- PHP extension
mongodb: 1.10+
Si necesitas usar una versión diferente, instálala manualmente:
composer require mongodb/laravel-mongodb:"YOUR_VERSION" ## 📦 Installation ### 1. Install via Composer ```bash composer require garcia1901l/laravel-activity-lite
Optional: Publish the configuration file:
php artisan vendor:publish --provider="Garcia1901l\LaravelActivityLite\ActivityLiteServiceProvider"
2. Run the installation command
php artisan activity-lite:install
This will:
- Create the MongoDB database
- Run the required migrations
🧑💻 Basic Usage
Add the trait to your models:
use Garcia1901l\LaravelActivityLite\Traits\LogsActivity; use Illuminate\Database\Eloquent\Model; class User extends Model { use LogsActivity; }
🔧 Advanced Usage
Manual Logging
User::logManualAction('custom_action', [ 'message' => 'Special event occurred', 'data' => ['key' => 'value'] ]);
Query Logs
# View recent activity php artisan activity-lite:query --days=7 # Filter by model php artisan activity-lite:query --model=User # Filter by action php artisan activity-lite:query --action=updated # Export results php artisan activity-lite:query --days=30 --json php artisan activity-lite:query --days=30 --csv
⚙️ Configuration
Publish the config file:
php artisan vendor:publish --tag=activity-lite-config
Example of config/activity-lite.php:
return [ 'enabled' => true, 'database_name' => 'activity_lite', 'events' => ['created', 'updated', 'deleted', 'soft_deleted', 'force_deleted', 'restored'], 'except' => [], // Models to exclude ];
🗃️ Database Structure
The activity_logs table includes:
| Column | Type | Description |
|---|---|---|
| id | bigint | Primary key |
| action | string | Performed action |
| log_type | string | 'model' or 'manual' |
| model_type | string | Model class |
| model_id | bigint | Model ID |
| causer_type | string | Who performed the action |
| causer_id | bigint | Causer ID |
| data | json | Change data |
| created_at | timestamp | Creation time |
| updated_at | timestamp | Last update time |
🛠️ Customization
Temporarily disable logging
config(['activity-lite.enabled' => false]);
Exclude specific models
'except' => [ App\Models\SensitiveModel::class, ],
Log only specific attributes and ignore others
public function getActivityLogOptions(): array { return [ 'log_attributes' => ['name', 'email'], 'ignore_attributes' => ['password', 'remember_token'] ]; }
✅ Requirements
- PHP 8.1+
- Laravel 10.x to 12.x
- MongoDB extension for PHP
📄 License
MIT License. See LICENSE for details.
👤 Author
Frank Garcia
garcia1901l/laravel-activity-lite 适用场景与选型建议
garcia1901l/laravel-activity-lite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mongodb」 「logger」 「monitoring」 「Audit」 「laravel」 「activity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 garcia1901l/laravel-activity-lite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 garcia1901l/laravel-activity-lite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 garcia1901l/laravel-activity-lite 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates Symfony2 documents, forms and CRUD
A Symfony bundle for chameleon-system/sanitycheck
SoftWax Health Check Bundle for Symfony framework
1Pilot client for Symfony
Workflow logger
HTTP request logger middleware for Laravel
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-09