Jump24 - Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

Laravel Activitylog

spatie/laravel-activitylog image

Laravel Activitylog stats

Downloads
16.6M
Stars
4,925
Open Issues
13
Forks
685

View on GitHub →

A very simple activity logger to monitor the users of your website or application

Laravel Activity Log Package Summary

The spatie/laravel-activitylog package is a robust tool designed to help developers log activities within their Laravel applications effortlessly. It offers a straightforward approach to tracking user interactions and system events, making it invaluable for auditing and monitoring purposes.

Key Features

  • Simple Logging: Quickly log activities with a minimal setup.
  • Eloquent Model Tracking: Automatically log events related to model changes.
  • Retrieval of Logs: Easily access logs using the Activity model.
  • Flexible Log Contexts: Enhance logs with custom properties, models, and causes.
  • Automatic Event Logging: Effortlessly log model events like create, update, and delete actions.

Installation and Setup

To get started with spatie/laravel-activitylog, you can install it via Composer:

composer require spatie/laravel-activitylog

After installation, publish and run the migrations:

php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
php artisan migrate

Optionally, you can publish the configuration file for further customization:

php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-config"

Usage

Logging activity is as simple as:

activity()->log('Log message');

For more advanced usage, such as logging actions performed on an eloquent model by a specific user, you can chain methods like so:

activity()
->performedOn($model)
->causedBy($user)
->log('Performed an action');

You can retrieve and inspect logged activities using:

$activity = Activity::all()->last();

Documentation and Support

Full documentation is available here, providing detailed instructions and advanced usage scenarios. For issues and feature requests, create an issue on GitHub.

Contributions and Security

Contributions are welcome, and for security issues, please email security@spatie.be directly.

License

The package is open-sourced under the MIT license, making it available for personal and commercial use.

In summary, the spatie/laravel-activitylog package is an essential tool for developers needing efficient and effective activity logging in Laravel applications, providing powerful features with minimal setup.

spatie photo

We create open source, digital products and courses for the developer community

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Spatie Laravel Activitylog Related Articles

Lens for Laravel Brings WCAG Auditing to Your Local Dev Workflow image

Lens for Laravel Brings WCAG Auditing to Your Local Dev Workflow

Read article
Nimbus: An In-Browser API Testing Playground for Laravel image

Nimbus: An In-Browser API Testing Playground for Laravel

Read article
Memoization and Function Caching with this PHP Package image

Memoization and Function Caching with this PHP Package

Read article
Use Passkeys in Your Laravel App image

Use Passkeys in Your Laravel App

Read article
Packistry is a Self-hosted Composer Repository Made with Laravel image

Packistry is a Self-hosted Composer Repository Made with Laravel

Read article
Laravel Backup Server v4 Released as Open Source image

Laravel Backup Server v4 Released as Open Source

Read article
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift