PHPackages                             tihloh/prefab-logs - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. tihloh/prefab-logs

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

tihloh/prefab-logs
==================

Standalone, framework-independent structured activity and audit logging for Prefab PHP.

v0.1.0(yesterday)01↑2900%MITPHPPHP &gt;=8.1

Since Aug 23Pushed yesterdayCompare

[ Source](https://github.com/tihloh/prefab-logs)[ Packagist](https://packagist.org/packages/tihloh/prefab-logs)[ Docs](https://github.com/tihloh/prefab-php)[ RSS](/packages/tihloh-prefab-logs/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Tihloh Prefab Logs
==================

[](#tihloh-prefab-logs)

Framework-independent structured logging for Tihloh Prefab PHP.

Prefab Logs is standalone. It does not require Users, Auth, Permissions, Prefab Database, Laravel, or another framework package.

Goals
-----

[](#goals)

- Accept structured audit/activity payloads from any module or project code.
- Keep actor, subject, changes, metadata, IP address, user agent, and timestamps.
- Store logs through `LogRepositoryInterface`.
- Accept plain PDO or Prefab's `DatabaseInterface` for the built-in repository.
- Automatically integrate with compatible Prefab modules when present.
- Present the same stored log in technical or ordinary-user-friendly form.

Standalone setup
----------------

[](#standalone-setup)

```
use Tihloh\Prefab\Logs\Repositories\PdoLogRepository;
use Tihloh\Prefab\Logs\Services\LogManager;

$logs = new LogManager(
    new PdoLogRepository($pdo),
);
```

The historical `PdoLogRepository` class name is retained for compatibility, but it now consumes `DatabaseInterface` internally. Passing PDO is automatically adapted.

A custom repository remains valid:

```
$logs = new LogManager($customRepository);
```

Automatic database configuration
--------------------------------

[](#automatic-database-configuration)

Direct configuration affects Logs only:

```
$logs = new LogManager([
    'database' => $logPdo,
]);
```

Central module-specific configuration is also supported:

```
PrefabConfig::set([
    'database' => $mainPdo,

    'modules' => [
        'logs' => [
            'connection' => 'logs',
            'table' => 'activity_logs',
        ],
    ],
]);
```

When Prefab Database exists, the named connection is resolved automatically.

```
1. direct Logs repository / database / connection
2. Logs-specific PrefabConfig
3. common PrefabConfig
4. compatible database capability
5. clear error if storage is still unresolved

```

Record a structured log
-----------------------

[](#record-a-structured-log)

```
$logs->record([
    'action' => 'user.updated',
    'subject_type' => 'user',
    'subject_id' => 25,
    'actor_id' => 7,
    'message' => 'User profile was updated.',
    'changes' => [
        'office' => [
            'old' => 'Accounting',
            'new' => 'Budget',
        ],
    ],
    'metadata' => [
        'source' => 'admin-ui',
    ],
]);
```

A `LogEntry` DTO may also be supplied directly.

Automatic Prefab activity logging
---------------------------------

[](#automatic-prefab-activity-logging)

When Logs exists, compatible Prefab modules can discover the `logger` capability automatically.

For example, Users, Auth, and Permissions can emit structured activity without the application manually forwarding every log payload.

```
$users = new UserManager();
$auth = new AuthManager();
$permissions = new PermissionManager();
$logs = new LogManager();
```

Explicit repositories/databases still override automatic storage choices.

Human-friendly and technical views
----------------------------------

[](#human-friendly-and-technical-views)

The database stores only one structured record.

Technical/audit view:

```
$technical = $logs->recent(50);
```

Ordinary-user view:

```
$human = $logs->humanRecent(
    50,
    actorResolver: fn ($id) => $users->find($id)?->name,
    subjectResolver: fn ($type, $id) => $type === 'user'
        ? $users->find($id)?->name
        : null,
);
```

For example, a technical `permission.denied` record can be presented compactly as:

```
Demo Admin denied View Documents for Test User.

```

The technical details remain available; the human representation does not duplicate database storage.

Query logs
----------

[](#query-logs)

```
$logs->recent();
$logs->find(1001);
$logs->forSubject('user', 25);
$logs->forActor(7);
```

Database abstraction
--------------------

[](#database-abstraction)

The built-in repository accepts:

```
PDO
DatabaseInterface

```

Plain PDO is normalized automatically:

```
PDO
 ↓
PdoDatabaseAdapter
 ↓
DatabaseInterface
 ↓
PdoLogRepository

```

The same contract can later be supplied by Prefab Database or a framework adapter.

Driver-specific table/index DDL remains isolated in the built-in repository for MySQL/MariaDB, PostgreSQL, SQLite, and SQL Server until a separate schema abstraction is justified.

Ownership
---------

[](#ownership)

Logs owns only its own storage table by default:

```
prefab_logs

```

It does not require or modify project user tables, permission tables, or business tables.

Diagnostics
-----------

[](#diagnostics)

Use:

```
$logs->explain();
```

to inspect where the repository, database, connection, and table configuration came from.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ec00222b22ba37eb69aff9973c5303fe5773cb4c7016bf0e7aae09fe9edb232?d=identicon)[tihloh](/maintainers/tihloh)

---

Top Contributors

[![tihloh](https://avatars.githubusercontent.com/u/8960509?v=4)](https://github.com/tihloh "tihloh (37 commits)")

---

Tags

phploggingmodularactivity-logaudit-logprefabframework-independent

### Embed Badge

![Health badge](/badges/tihloh-prefab-logs/health.svg)

```
[![Health](https://phpackages.com/badges/tihloh-prefab-logs/health.svg)](https://phpackages.com/packages/tihloh-prefab-logs)
```

###  Alternatives

[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1871.6M3](/packages/justbetter-magento2-sentry)[muhammadsadeeq/laravel-activitylog-ui

A beautiful, modern UI for Spatie's Activity Log with advanced filtering, analytics, and real-time features.

17920.1k](/packages/muhammadsadeeq-laravel-activitylog-ui)

PHPackages © 2026

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