gitmyhub

laravel-activitylog

PHP ★ 5.8k updated 2d ago

Log activity inside your Laravel app

This is a PHP package for the Laravel web framework that records what users and the system do inside your application. It stores those records in a database table called activity_log. Think of it as an audit trail: who did what, when, and to which piece of data.

You can log things manually with a single line of code. You can attach context to each log entry: which database record was affected (the subject), which user caused the action (the causer), and any additional custom properties you want to store. You can then query all logged activities using a standard Laravel model.

The package can also log model events automatically. When a database record is created, updated, or deleted, the package notices and writes a log entry without you needing to add any extra code. For updates, it records both the old values and the new values, so you can see exactly what changed. This makes it useful for audit logging in applications where you need to track changes to records over time.

Installation is done through Composer, the standard PHP package manager. After installing, you run a database migration command to create the activity_log table. There is also an optional configuration file you can publish if you want to adjust the package behavior, such as changing the format of the ID fields to match UUIDs instead of integers.

Full documentation is hosted at spatie.be. The package is maintained by Spatie, a Belgian web development agency that publishes many open source Laravel packages. It is licensed under the MIT License.