PHPackages                             tetthys/activity-log - 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. tetthys/activity-log

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tetthys/activity-log
====================

Framework-agnostic activity log core with Enum/Attribute definitions and high-performance counter-backed stats. Optional Laravel 12 integration included.

0.0.1(5mo ago)04MITPHPPHP ^8.1

Since Jan 15Pushed 5mo agoCompare

[ Source](https://github.com/tetthys/activity-log)[ Packagist](https://packagist.org/packages/tetthys/activity-log)[ RSS](/packages/tetthys-activity-log/feed)WikiDiscussions dev Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

tetthys/activity-log
====================

[](#tetthysactivity-log)

A **query-first activity logging system** for PHP 8.x, built around **Enums and Attributes**.

This package provides a clean alternative to the “one table per action” pattern by combining:

- a single append-only activity log
- attribute-driven validation and policy
- counter-backed fast reads for analytics

The core is framework-agnostic, with an optional **Laravel 12 integration**.

---

Why this exists
---------------

[](#why-this-exists)

Most applications eventually need to answer questions like:

- How many times did a user perform an action?
- How often does this happen per day?
- How many times did a user interact with a specific resource?

Traditional logging approaches make these questions expensive by forcing full table scans or ad-hoc aggregation queries.

**tetthys/activity-log** is designed so that:

- actions are explicitly defined
- counting rules are declared up front
- reads are fast by default

---

Core Ideas (Quick Overview)
---------------------------

[](#core-ideas-quick-overview)

### 1. Actions are Enums

[](#1-actions-are-enums)

Instead of logging arbitrary strings, every activity is a **typed enum case**.

Each case declares:

- its public name
- whether an actor is required
- whether a target object is required
- what metadata is allowed
- how the action should be counted

The enum becomes the **single source of truth**.

---

### 2. Two data layers

[](#2-two-data-layers)

LayerPurpose`activity_logs`Append-only event log (auditing, debugging, history)`activity_counters`Pre-aggregated counters for fast queriesThe log table is never scanned for common queries.

---

### 3. Queryability is built in

[](#3-queryability-is-built-in)

Actions explicitly declare what should be counted:

- per actor
- per object
- per actor + object
- per time bucket (day, hour)

This makes common analytics **O(1)** or small range reads.

---

Defining Actions (Generic Example)
----------------------------------

[](#defining-actions-generic-example)

```
