Download the PHP package gottvergessen/activity without Composer
On this page you can find all versions of the php package gottvergessen/activity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gottvergessen/activity
More information about gottvergessen/activity
Files in gottvergessen/activity
Package activity
Short Description A lightweight Laravel activity logging package that tracks model events with automatic observers.
License MIT
Homepage https://github.com/barsch123/activity
Informations about the package activity
activity
Lightweight Laravel activity logging package.
Goal
Make this package installable by consumers via Composer and Packagist.
Steps to publish
- Create a standalone GitHub repository (e.g.
gottvergessen/activity) and push thisactivity/folder as the repository root. - On Packagist, submit the repository or enable GitHub auto-update.
- In the GitHub repository, add a secret named
PACKAGIST_TOKENwith your Packagist API token. - Create a tag (e.g.
v1.0.0) and push the tag; the workflow will notify Packagist to update.
Installation (for consumers)
After publishing to Packagist, consumers can run:
Development notes
- This package uses PSR-4 autoloading defined in
composer.json. - Tests use
orchestra/testbenchandpest.
CI
The repository includes a GitHub Actions workflow that notifies Packagist on new tags. See .github/workflows/notify-packagist.yml.
Logger
Logger is a lightweight, opinionated activity logging package for Laravel that automatically tracks model changes and records who did what, to which model, and when — without polluting your domain logic.
Features:
- Automatic tracking of model changes (create, update, delete, restore)
- Privacy-first with explicit opt-in for sensitive data
- Flexible configuration per model or globally
- Query scopes for easy filtering and analysis
- Batch operations to group related changes
- Lightweight and performant
- Built-in pruning command for cleanup
- Comprehensive audit trails
Installation
You can install the package via composer:
Publish Assets
Publish the configuration file and migrations:
This will create:
config/activity.php- Configuration filedatabase/migrations/[timestamp]_create_logger_table.php- Database migration
You can also publish assets separately:
Run Migrations
After publishing, run the migrations to create the activity_logs table:
Pruning Old Logs
To keep your database clean, you can prune old activity logs:
config/activity.php
Basic usage
Now all changes to the User model are automatically logged:
Log Relation-Only Changes (Pivot Attach/Detach/Sync)
Pivot operations like syncWithoutDetaching() and detach() do not mutate
the tracked model's own attributes, so they won't produce automatic updated
activity entries by themselves.
Use logActivity() in your model methods to explicitly record those changes:
Ignore Specific Fields per Model
Ignore Seeding
If you seed data during local development or tests, you can keep the package from
recording those model events by leaving activity.ignore_seeding enabled.
Set it to false if you want seeder-driven model changes to be logged too.
Database Schema
The activity_logs table tracks the following information:
| Column | Type | Description |
|---|---|---|
| id | ID | Primary key |
| event | string | The event type (created, updated, deleted, restored). Events can be resolved into custom actions and descriptions |
| action | string | Custom semantic action defined by the model (optional) |
| log | string | Log category for grouping activities |
| description | string | Description of the activity (optional) |
| subject_type | string | The model class that was changed |
| subject_id | int | The ID of the model that was changed |
| causer_type | string | The model class of the user who made the change (optional) |
| causer_id | int | The ID of the user who made the change (optional) |
| properties | json | The model attributes that changed |
| meta | json | Metadata including IP, user agent, HTTP method, and host |
| batch_id | string | Batch ID for grouping related changes (optional) |
| created_at | timestamp | When the activity was recorded |
| updated_at | timestamp | When the activity record was last updated |
Eloquent Friendly
Add the InteractsWithActivity trait to easily query a model's activities:
Now you can access activities directly from your models:
The InteractsWithActivity trait is optional and only required if you want to access $model->activities().
Per-Model Event Control
Advanced Usage
Custom Log Name per Model
Custom Action per Model
Custom Description per Model
Batch Operations
Group multiple model changes under a single batch ID:
Temporarily Disable Logging
You can temporarily disable activity logging when needed:
Query Scopes
The Activity model provides convenient query scopes:
Audit Trail
Document History
For more examples and patterns, see EXAMPLES.md.
License
The MIT License (MIT). Please see License File for more information.
All versions of activity with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
spatie/laravel-package-tools Version ^1.16