PHPackages                             minvws/audit-logger - 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. minvws/audit-logger

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

minvws/audit-logger
===================

Generic audit logger

1.0.0(1mo ago)038.8k↓22.7%2EUPL-1.2PHPPHP ^8.3CI passing

Since Sep 13Pushed 4mo ago9 watchersCompare

[ Source](https://github.com/minvws/nl-rdo-php-audit-logger)[ Packagist](https://packagist.org/packages/minvws/audit-logger)[ RSS](/packages/minvws-audit-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (28)Versions (16)Used By (2)

PHP Audit Logger (nl-rdo-audit-logger)
======================================

[](#php-audit-logger-nl-rdo-audit-logger)

This package provides a generic logging service for the RDO platform. It allows to easily log events to the database, syslog or other destinations.

Log events can be logged with or without PII data. PII data is data that can be used to identify a person. Depending on the logging destination, it can send the PII data or not.

Data can be automatically encrypted with a public/private keypair so that logging can be written, but not directly read.

This package is a generic module that isn't directly coupled to a framework, however, there are other packages that provide a framework specific implementation.

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

[](#installation)

### Requirements

[](#requirements)

- PHP &gt;= 8.1
- Composer

### Composer

[](#composer)

You can install the package via the composer package manager:

```
composer require minvws/audit-logger
```

### Configuration

[](#configuration)

#### PSR logging

[](#psr-logging)

With the PSRLogger you can log through any PSR compatible logger. This makes it easy to log to any destination like syslog, or monolog.

##### Encryption

[](#encryption)

Audit lines can optionally be encrypted so they can only be read by the application that has the private key.

To generate a new keypair, use the following code:

```
$kp = sodium_crypto_box_keypair();
$pubkey = sodium_crypto_box_publickey($kp);
$privkey = sodium_crypto_box_secretkey($kp);

echo "Public key: " . base64_encode($pubkey) . "\n";
echo "Private key: " . base64_encode($privkey) . "\n";
```

#### Logging full request

[](#logging-full-request)

The option `log_full_request` can be used to log the full HTTP request. Any sensitive information like passwords, tokens etc should be stripped from the request. However, there is no guarantee that all sensitive information will be stripped if the naming is different.

However, this configuration option is NOT implemented. You MUST call `logFullRequest()` on the event in order to log the full request.

### Usage

[](#usage)

To use the logger, inject or resolve the `LogService` class. This class has a single method:

```
  $logger = app(LogService::class);
  $logger->log((new UserLoginLogEvent())
      ->asExecute()
      ->withActor($user)
      ->withData(['foo' => 'bar'])
      ->withPiiData(['bar' => 'baz'])
      ->withFailed(true, 'invalid login')
  );
```

To create an event, you can use the fluent interface to create the event. Two elements are always required: the action code and the actor.

The action code is a string that describes the action that was performed. This could be 'create', 'delete', 'update', 'read' or 'execute'. These are defined with the `->asCreate()`, `->asDelete()`, `->asUpdate()`, `->asRead()` and `->asExecute()` methods.

Next, we need to define the actor that performed the action. This can be a user, a client or a system. This is done with the `->withActor()` method. It will need a user that implements the `LoggableUser` interface.

The event can have some additional fields:

`->withTarget` can be used to define the target of the action. This can be a user, a client or a system. This can be empty if the actor and target are the same, but different when an actor performs an action onto a target (for instance, an admin (actor) creates a regular user (target)).

`->withData` can be used to add additional data to the event. This can be any data that is relevant to the event.

`->withPiiData` can be used to add PII data to the event. This can be any data that is relevant to the event and contains PII data. Depending on the logging configuration, this data might or might not be send to a logger destination.

`->withFailed` can be used to mark the event as failed. This will add the `failed` field to the event and set it to `true`. The second parameter can be used to add a reason for the failure.

`->withSource` can be used to add a source to the event. This can be any string that describes the source of the event. It's often nothing more than the name of the application (`->withSource(config('app.name'))`).

`->withEventCode` can be used to add an event code to the event. This can be any string that describes the event. Often it's already defined by the event class, but it can be overridden.

`->logFullRequest` can be used to log the full HTTP request. Any sensitive information like passsords, tokens etc will be stripped from the request.

Events
------

[](#events)

Each event has a unique event code. This code is used to identify the event and can be used to filter events in your logs. For rabbitMQ logging, each event will have a unique routing key that can be used to route events to different queues.

ClassEvent coderouting keyDescriptionDeclarationLogEvent080001declarationDeclaration eventLogAccessEvent080002log\_accessAccessing logsVerificationCodeDisabledLogEvent080003verification\_code\_disabledDisabled verification codeRegistrationLogEvent080004registrationRegistration event-----------------------------------------------------------------------------AccountChangeLogEvent090001account\_changegeneric user account changesUserCreatedLogEvent090002user\_createdcreated new userResetCredentialsLogEvent090003reset\_credentialsreset user credentialsActivateAccountLogEvent090004activate\_accountActivate accountAdminPasswordResetLogEvent090005admin\_password\_resetAdmin password resetAmpUploadEvent090006amp\_uploadAMP upload-----------------------------------------------------------------------------OrganisationCreatedLogEvent090012organisation\_createdCreated new organisationOrganisationChangedLogEvent090013organisation\_changedUpdated organisation (name)-----------------------------------------------------------------------------AccountChangeLogEvent[1](#user-content-fn-1-92ea56eb1f6fbf62c6fe60e69af58a84)900101account\_changechanged user dataAccountChangeLogEvent900102account\_changechanged rolesAccountChangeLogEvent900103account\_changechanged timeslotAccountChangeLogEvent900104account\_changechanged active enabled/disabledAccountChangeLogEvent900105account\_changereset credentials--------------------------------------------------------------------------------------------------------------AccountChangeLogEvent900201account\_changechanged kvtb user dataAccountChangeLogEvent900202account\_changechanged kvtb rolesAccountChangeLogEvent900203account\_changereset kvtb credentials--------------------------------------------------------------------------------------------------------------UserLoginLogEvent091111user\_loginuser loginUserLogoutLogEvent092222user\_logoutuser logoutUserLoginTwoFactorFailedEvent093333user\_login\_two\_factor\_faileduser login 2fa failed### Creating custom events

[](#creating-custom-events)

Creating a custom event is easy. You can create a new class that extends the `GeneralLogEvent` class.

```
  class MyCustomEvent extends GeneralLogEvent
  {
      public const EVENT_CODE = '991414';
      public const EVENT_KEY = 'my_custom_event';
  }
```

Usage in other frameworks
-------------------------

[](#usage-in-other-frameworks)

This package is framework agnostic. However, there are other packages that provide a framework specific implementation.

- Laravel: [minvws/nl-rdo-laravel-logging](https://github.com/minvws/nl-rdo-laravel-logging)
- Symfony: [minvws/nl-rdo-php-audit-logger-bundle](https://github.com/minvws/nl-rdo-php-audit-logger-bundle)

Contributing
------------

[](#contributing)

If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository of this package.

License
-------

[](#license)

This package is open-source and released under the European Union Public License version 1.2. You are free to use, modify, and distribute the package in accordance with the terms of the license.

Part of iCore
-------------

[](#part-of-icore)

This package is part of the iCore project.

Footnotes
---------

1. This event is used for all account changes. The event code is used to identify the type of change. Set this with the `->withEventCode()` method. [↩](#user-content-fnref-1-92ea56eb1f6fbf62c6fe60e69af58a84)

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance80

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~229 days

Total

5

Last Release

54d ago

Major Versions

0.4.0 → 1.0.02026-03-25

PHP version history (3 changes)0.1.0PHP ^8.0

0.2.0PHP ^8.1

1.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/35585f12d5551026d3cf7e8e25170cd718a16a5017096b3201ed196311ac51d9?d=identicon)[annejan](/maintainers/annejan)

![](https://www.gravatar.com/avatar/af4eb8b647eac85c766fcee704f0af54b43844b30a80f7eb3e83dde0b8a50815?d=identicon)[ricklambrechts](/maintainers/ricklambrechts)

![](https://www.gravatar.com/avatar/44e7cc7a950c1f964d8c8a5e3421d5fa61d6592add09ee3936ed267d75b2be33?d=identicon)[rdobeheer](/maintainers/rdobeheer)

---

Top Contributors

[![jaytaph](https://avatars.githubusercontent.com/u/241458?v=4)](https://github.com/jaytaph "jaytaph (12 commits)")[![lkeijmel](https://avatars.githubusercontent.com/u/532438?v=4)](https://github.com/lkeijmel "lkeijmel (5 commits)")[![randh1r](https://avatars.githubusercontent.com/u/17409257?v=4)](https://github.com/randh1r "randh1r (3 commits)")[![annejan](https://avatars.githubusercontent.com/u/294470?v=4)](https://github.com/annejan "annejan (2 commits)")[![basdenooijer](https://avatars.githubusercontent.com/u/580644?v=4)](https://github.com/basdenooijer "basdenooijer (2 commits)")[![Ilyes512](https://avatars.githubusercontent.com/u/2445415?v=4)](https://github.com/Ilyes512 "Ilyes512 (2 commits)")[![sigio](https://avatars.githubusercontent.com/u/781641?v=4)](https://github.com/sigio "sigio (2 commits)")[![pk27734](https://avatars.githubusercontent.com/u/70482?v=4)](https://github.com/pk27734 "pk27734 (1 commits)")[![ricklambrechts](https://avatars.githubusercontent.com/u/1367665?v=4)](https://github.com/ricklambrechts "ricklambrechts (1 commits)")[![ppvg](https://avatars.githubusercontent.com/u/67802?v=4)](https://github.com/ppvg "ppvg (1 commits)")

---

Tags

icoreloggingAudit

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/minvws-audit-logger/health.svg)

```
[![Health](https://phpackages.com/badges/minvws-audit-logger/health.svg)](https://phpackages.com/packages/minvws-audit-logger)
```

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[nelmio/js-logger-bundle

Adds logging of JS errors in your Symfony application

1761.2M](/packages/nelmio-js-logger-bundle)[bedezign/yii2-audit

Yii2 Audit records and displays web/cli requests, database changes, php/js errors and associated data.

201657.4k4](/packages/bedezign-yii2-audit)[open-telemetry/api

API for OpenTelemetry PHP.

1933.0M214](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)

PHPackages © 2026

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