Skip to content
CAI
Software that uses CAICheck a score

spatie/laravel-activitylog

67.9

Adequate · 17 November 2026

1.5k

lines of production code

PHP

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Added activity log cleanup command and typed activity event enum

Users can now clean old records from the activity log via the new \activitylog:clean\ Artisan command, which accepts optional \log\ and \--days\ arguments to specify which logs to clear and how far back to look, while enforcing that the days value is a positive integer. Additionally, activity events are now represented by the new \ActivityEvent\ enum (Created, Updated, Deleted, Restored), providing a typed way to reference these standard operations within the package.

src/Commands, src/Enums · high confidence

Added activity\_log table migration stub

A new migration stub file has been added to the database/migrations directory to define the schema for the 'activity\_log' table. This stub creates the table with columns for ID, log name, description, subject and causer polymorphic relationships, event type, JSON attributes and properties, and timestamps, providing the necessary database structure for the package's activity logging feature.

database · high confidence

Initial configuration file for Activity Log package

The package now provides a \config/activitylog.php\ file that allows users to customize activity logging behavior. Key configurable options include enabling or disabling logging, setting the number of days to retain logs (\clean\_after\_days\), defining the default log name, specifying a custom authentication driver, and toggling the inclusion of soft-deleted subjects. Users can also configure the activity model class, set default attributes to exclude from logs, enable a memory buffer for bulk logging to improve performance under high load, and override the default action classes for logging and cleaning.

config · high confidence

Introduces Activity contract for activity log models

A new \Activity\ interface has been added to the contracts layer, defining the required methods for activity log models. This contract specifies that implementing classes must provide \subject()\ and \causer()\ relationships (returning \MorphTo\) and a \getProperty()\ method to retrieve specific property values with an optional default. This standardizes the API for interacting with activity log entries across the application.

src/Contracts · high confidence

New Activity facade for fluent activity logging

A new \Activity\ facade has been added to the library, providing a static interface for the \PendingActivityLog\ service. This allows users to fluently construct and log activities using method chaining (e.g., \Activity::causedBy($user)-\>log('Updated profile')\) without needing to manually resolve the underlying service from the container. The facade is configured to bypass caching (\$cached = false\) to ensure that the builder instance remains fresh for each call, supporting the fluent API pattern.

src/Facades · high confidence

Behavioural changes

Activity logging now defers saves until after database transactions commit

The activity logging mechanism has been updated to prevent data loss or inconsistency when logging occurs within database transactions. The LogActivityAction now detects active transactions and, instead of saving immediately, registers a callback to persist the activity record only after the transaction successfully commits. This ensures that activity logs are only written when the associated database changes are permanent, fixing issues where logs might be lost on rollback or saved out of order.

src/Actions · high confidence

Activity logging now uses an explicit event type and supports BackedEnum log names

The Activity model now includes an \event\ column and a \scopeForEvent\ query scope, allowing users to filter activity logs by specific event types (e.g., created, updated, deleted) rather than relying solely on the description. Additionally, the \scopeInLog\ filter now accepts \BackedEnum\ values for log names, enabling type-safe filtering using the new \ActivityEvent\ enum. The \LogsActivity\ trait has been updated to automatically set this event type based on the model's lifecycle events, and the \CausesActivity\ and \HasActivity\ traits provide standardized relationships for accessing these logs.

src/Models · high confidence

Introduction of specific exception classes for configuration and logging errors

The library now provides dedicated exception classes to handle specific error scenarios during activity logging. An \InvalidConfiguration\ exception has been added to signal issues when a provided model class does not implement the required \Activity\ contract or extend the \Model\ base class, or when an action class does not extend the expected base class. Additionally, a \CouldNotLogActivity\ exception has been introduced to handle cases where a user cannot be determined by a given identifier, replacing the previous placeholder test scaffolding.

src/Exceptions · high confidence

Modernized activity logging with BackedEnum support and new support classes

The \src/Support\ directory has been completely rewritten to support PHP 8.4+ and Laravel 11+. This update introduces several new support classes: \ActivityBuffer\ for batching activity inserts, \ActivityLogStatus\ for managing logging enable/disable states, \ActivityLogger\ as the fluent logging interface, \CauserResolver\ for resolving the user who triggered an activity, \ChangeDetector\ for identifying attribute changes, \Config\ for resolving activity models and actions, \LogOptions\ for configuring model-level logging behavior, and \PendingActivityLog\ for chaining logging operations. A key behavioral change is the addition of BackedEnum support for log names and events in \ActivityLogger\ and \LogOptions\, allowing users to pass enum instances (e.g., \ActivityEvent::updated\) instead of strings. The \ActivityLogger\ now uses a builder pattern with methods like \performedOn()\, \causedBy()\, \event()\, and \withChanges()\ to construct activity logs. Also in this area: 1 commit (0 fixes) modifying src/Support; 1 commit (1 fix) fixing src/Support; Defers default causer resolution until activity logging.

src/Support · medium confidence · unverified

Replaces skeleton template with Laravel Activitylog service provider and helper

The skeleton package scaffolding (SkeletonClass, SkeletonFacade, and SkeletonServiceProvider) has been removed and replaced by the actual Laravel Activitylog implementation. The new ActivitylogServiceProvider registers the activity logger as a bound instance and scopes the CauserResolver, ActivityLogStatus, and ActivityBuffer services to the request lifecycle. It also configures the ActivityBuffer to flush on request termination, after successful/failed queue jobs, and during PHP shutdown when buffering is enabled. A global activity() helper function is provided to create pending activity logs with an optional log name.

src · high confidence

Updated Boost guidelines for activity logging

The Boost development guidelines have been reorganized to improve usability when specific skills are unavailable. The core guidelines now instruct developers to activate the \activitylog-development\ skill when working with \spatie/laravel-activitylog\ features, and provide a fallback path to read the skill's documentation directly from the vendor directory if the skill is not present. A new \activitylog-development\ skill file has been added, detailing how to use traits like \LogsActivity\ and \CausesActivity\, configure \LogOptions\, perform manual logging, and customize activity models and actions.

resources · high confidence

Upgrade to v5 with PHP 8.4+ and Laravel 12+ requirements

The package has been upgraded to version 5, which raises the minimum requirements to PHP 8.4+ and Laravel 12+. This release introduces a modernized API and a new database schema: the \properties\ column now stores only custom user data, while a new \attribute\_changes\ column tracks model changes. The batch system has been removed, and several methods and properties have been renamed (e.g., \getExtraProperty()\ to \getProperty()\, \$activity-\>changes\ to \$activity-\>attribute\_changes\). Configuration keys have also been updated, such as \delete\_records\_older\_than\_days\ to \clean\_after\_days\. Existing users upgrading from v4 must run a migration to adapt their database schema and update their code to reflect the API changes.

(repo-wide) · high confidence

Test coverage

Added test helper enums for activity log testing; Added test infrastructure and custom cast tests; Added test suite for Activity model scopes and custom model configurations; Added tests for activity logging support components; Added tests for the activity log cleaning command.

Dependencies

Upgrade to Laravel 12/13 and PHP 8.4 with Pest testing

The package now requires PHP 8.4 and supports Laravel 12 and 13, dropping compatibility with older versions. Development tools have been modernized by switching from PHPUnit to Pest for testing, and the testbench dependency has been updated to version 10 or 11 to align with the new Laravel versions.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 67.8 → 67.9 (+0.1)
  • Rubric changed (rubric-2026.11.2 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 70.6 → 70.6 (0.0)
  • Architecture 69.0 → 69.0 (0.0)
  • Maturity 65.6 → 65.6 (0.0)
  • Readiness 83.5 → 85.2 (+1.7)
  • Security 67.7 → 67.7 (0.0)

Resolved (1)

  • Off-boarding risk: anonymized user #1

New (2)

  • Circular dependency (src/Actions/CleanActivityLogAction.php)
  • Off-boarding risk: anonymized user #1

Changes since last survey

  • 6 commits — 4 feature/other, 2 fixes

By area

  • (root) — 3 commits
  • (repo) — 1 commit
  • docs/advanced-usage — 1 commit
  • src/Support — 1 commit

Notable commits

  • fix: Fix buffered activities with different attributes
  • fix: Merge pull request #1480 from AleksandrSpicyn/contrib/fix-buffer-mixed-attributes
  • change: Test PHP 8.6 with the current Pest stack (#1479)
  • change: Update CHANGELOG
  • change: Update CHANGELOG
  • change: Use the timestamp columns of the activity model when flushing the buffer (#1481)

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

spatie/laravel-activitylog was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 17 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit fdcc5ee063cbf91114679336c4fbf92837196419 — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.85+preprod-eba6548ac50f.