Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Activitylog Laravel Package

spatie/laravel-activitylog

Log user and model activity in Laravel with a simple API. Automatically record Eloquent events, track subjects and causers, attach custom properties, and query everything via the Activity model. Stores logs in the activity_log table.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Audit Trails & Compliance: Enables tracking of user actions (e.g., CRUD operations, API calls) for GDPR, SOX, or internal audits without building custom logging systems.
  • Debugging & Observability: Provides granular visibility into system interactions (e.g., "Who updated this record? What changed?") to accelerate issue resolution.
  • Feature Roadmap: Supports future plans for:
    • Admin Dashboards: Integrate with Laravel Nova or custom admin panels to display activity feeds.
    • Event-Driven Workflows: Trigger notifications/alerts (e.g., Slack, email) based on logged activities (e.g., "High-value record modified").
    • Machine Learning: Anonymize logs to train models for anomaly detection (e.g., fraud, data leaks).
  • Build vs. Buy: Buy—avoids reinventing audit logging wheels; Build only if needing highly specialized logging (e.g., real-time analytics).
  • Use Cases:
    • SaaS Platforms: Track tenant/user actions across multi-tenant apps.
    • E-Commerce: Log inventory changes, order modifications, or refunds.
    • Internal Tools: Monitor admin actions in CMS, HR, or finance systems.

When to Consider This Package

  • Adopt if:

    • Your Laravel app requires user activity tracking (e.g., "Who did what, when, and why?").
    • You need automated model event logging (e.g., Eloquent created, updated, deleted).
    • Your team lacks bandwidth to build/maintain a custom audit system.
    • You want extensibility (e.g., custom properties, filters, or storage backends like Redis).
    • Compliance (e.g., GDPR, HIPAA) mandates immutable activity logs.
  • Look Elsewhere if:

    • You need real-time streaming (e.g., Kafka, WebSockets)—this package is database-centric.
    • Your app uses non-Eloquent models (e.g., raw SQL, GraphQL mutations).
    • You require advanced analytics (e.g., aggregations, dashboards)—consider pairing with Laravel Scout or custom ETL.
    • Your logging needs cross-language support (e.g., Node.js, Python)—this is PHP-only.
    • You’re on a tight budget and need enterprise support (Spatie offers paid products but this is MIT-licensed).

How to Pitch It (Stakeholders)

For Executives:

"This package lets us automatically track every user action in our Laravel app—like a digital breadcrumb trail—without extra dev work. It’s MIT-licensed, battle-tested (5.8K GitHub stars), and solves compliance/audit needs out-of-the-box. For example, if a customer disputes a charge, we can instantly show who modified their account. It’s a force multiplier for support, security, and trust."

ROI:

  • Reduces compliance risk (e.g., GDPR fines) by ensuring immutable logs.
  • Cuts debugging time by 30%+ with granular activity data.
  • Enables new features (e.g., admin dashboards, alerts) with minimal dev lift.

For Engineers:

*"This is a drop-in solution for audit logging in Laravel. Key benefits:

  • Zero setup for basic use: Log activities with activity()->log('Action') or auto-capture Eloquent events.
  • Flexible: Customize log properties, disable logging per-request, or extend storage (e.g., Redis).
  • Performance: Optimized for production (e.g., clean_after_days config to prune old logs).
  • Integrations: Works with Laravel Nova, Scout, or custom APIs.

Trade-offs:

  • Database-bound (not ideal for high-throughput apps).
  • Requires a migration (activity_log table).

Example Use Case:

// Auto-log model updates
$post->title = 'New Title';
$post->save(); // Logs: 'updated', with `attribute_changes` diff.

// Manual logging
activity()
   ->performedOn($post)
   ->causedBy(auth()->user())
   ->withProperties(['ip' => request()->ip()])
   ->log('Published post');

Next Steps:

  1. Pilot: Add to a non-critical module (e.g., admin panel).
  2. Extend: Customize the Activity model or config for your needs.
  3. Monitor: Use Activity::all() to verify logs during testing.

Alternatives Considered:

  • Roll our own: Higher maintenance, no community support.
  • Third-party SaaS: Adds vendor lock-in and cost.
  • Laravel Debugbar: Lacks persistence and audit features.

Recommendation: Adopt for MVP, then iterate based on usage patterns."*

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport