PHPackages                             justinholtweb/craft-rat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. justinholtweb/craft-rat

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

justinholtweb/craft-rat
=======================

Track which users made edits to all content types on your Craft CMS site

5.1.0(3w ago)01proprietaryPHPPHP ^8.2

Since Jun 12Pushed 6d agoCompare

[ Source](https://github.com/justinholtweb/craft-rat)[ Packagist](https://packagist.org/packages/justinholtweb/craft-rat)[ RSS](/packages/justinholtweb-craft-rat/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (4)Versions (3)Used By (0)

Rat for Craft CMS 5
===================

[](#rat-for-craft-cms-5)

Track which users made edits to all content types on your Craft CMS site. Rat logs every element save with user attribution, changed fields, and timestamps — then surfaces that history in a dashboard widget and per-element sidebar panel.

Full documentation: [craft-rat.com](https://craft-rat.com)

Requirements
------------

[](#requirements)

- Craft CMS 5.3 or later
- PHP 8.2 or later

Installation
------------

[](#installation)

Open your terminal and run:

```
composer require justinholtweb/craft-rat
php craft plugin/install rat
```

Or install via the Craft control panel under **Settings &gt; Plugins**.

Features
--------

[](#features)

### Automatic Edit Tracking

[](#automatic-edit-tracking)

Rat listens for saves on all element types and logs who made the change, what fields were modified, and whether the element was created or updated. Drafts, revisions, propagating saves, and bulk resaves are automatically filtered out.

Supported element types:

- Entries, Assets, Globals, Categories, Tags, Users
- Craft Commerce Products, Variants, and Orders (if Commerce is installed)
- Any custom element type

### Dashboard Widget

[](#dashboard-widget)

Add the **Recent Edits** widget to your dashboard to see a live feed of edit activity across the site. Each row shows the user, element name (linked to its edit page), element type, action (created or edited), and a relative timestamp. The display limit is configurable from 1 to 100.

### Element Sidebar

[](#element-sidebar)

Every element edit page gets an **Edit History** panel in the sidebar showing the last 10 edits with user photos, action type, changed fields, and timestamps. A "View more..." link loads additional history via AJAX.

### Multi-Site Support

[](#multi-site-support)

Edits are tracked per site, so multi-site installs get accurate per-site history.

### Permissions

[](#permissions)

Edit history is only ever shown to users who could open the element themselves. Rat defers to Craft's own `canView` check, so section permissions, peer-entry rules, and site access all apply:

- The **Recent Edits** widget only lists edits to elements the viewing user can access. An editor limited to one section won't see titles from any other.
- The element-history endpoint returns a 403 for elements the user isn't authorized to view.

Admins see everything, including edits to elements that have since been deleted.

How It Works
------------

[](#how-it-works)

Rat registers a single `Element::EVENT_AFTER_SAVE` listener on the base `Element` class, so all element types are covered without needing individual listeners. Each save is recorded to a `rat_editlog` database table with the element ID, site ID, user ID, element type, label, and a JSON list of changed field names.

The sidebar uses `Element::EVENT_DEFINE_SIDEBAR_HTML` to inject edit history into every element edit page. The widget is registered via `Dashboard::EVENT_REGISTER_WIDGET_TYPES`.

Cleanup
-------

[](#cleanup)

Rat includes a `cleanupOldLogs` method that removes records older than a given number of days (default 90). This is not scheduled automatically — call it from a console command or cron job if needed:

```
use justinholtweb\rat\Plugin as Rat;

Rat::getInstance()->editTracker->cleanupOldLogs(90);
```

Configuration
-------------

[](#configuration)

Rat works out of the box with no configuration. Install and go.

Development
-----------

[](#development)

The repo ships with a [DDEV](https://ddev.com) environment so the test suite has a PHP runtime and a database without needing a full Craft install:

```
ddev start
ddev composer install
ddev mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
```

### Tests

[](#tests)

Two Codeception suites:

- **`unit`** — pure PHPUnit tests over logic that doesn't need a booted Craft app. Fast, no database.
- **`integration`** — boots a real Craft application against a throwaway `test` schema using Craft's own Codeception module, installs the plugin, and exercises it end to end through real element saves. Each test runs in a transaction that's rolled back afterwards.

```
ddev composer test               # both suites
ddev composer test-unit
ddev composer test-integration
```

The unit suite can also be run directly through PHPUnit via `ddev exec vendor/bin/phpunit`.

Test database credentials live in `tests/.env` and point at the DDEV database container. They only ever address the throwaway `test` schema, which the suite drops and recreates on every run.

License
-------

[](#license)

See [LICENSE.md](LICENSE.md).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance97

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Total

2

Last Release

23d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/035cb655c55af0e9e5b96754b80fd9703e195c32dbdfc49ae9a43ab9cf8db560?d=identicon)[justinholtweb](/maintainers/justinholtweb)

---

Top Contributors

[![justinholtweb](https://avatars.githubusercontent.com/u/295903?v=4)](https://github.com/justinholtweb "justinholtweb (6 commits)")

---

Tags

cmsAuditCraftcraftcmschangelogedit tracking

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/justinholtweb-craft-rat/health.svg)

```
[![Health](https://phpackages.com/badges/justinholtweb-craft-rat/health.svg)](https://phpackages.com/packages/justinholtweb-craft-rat)
```

###  Alternatives

[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

293952.6k34](/packages/craftcms-feed-me)[verbb/formie

The most user-friendly forms plugin for Craft.

101393.6k74](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.9k1](/packages/verbb-comments)[verbb/navigation

Create navigation menus for your site.

92705.0k19](/packages/verbb-navigation)[verbb/vizy

A flexible visual editor field for Craft.

4250.4k](/packages/verbb-vizy)[verbb/hyper

A user-friendly links field for Craft.

24147.8k12](/packages/verbb-hyper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
