PHPackages                             ksardv/php-log-sanitizer - 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. ksardv/php-log-sanitizer

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

ksardv/php-log-sanitizer
========================

A PHP package to hide or mask sensitive data in logs.

v1.0.1(11mo ago)02MITPHPPHP &gt;=8.0

Since May 10Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/ksardv/php-log-sanitizer)[ Packagist](https://packagist.org/packages/ksardv/php-log-sanitizer)[ RSS](/packages/ksardv-php-log-sanitizer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

PHP Log Sanitizer
=================

[](#php-log-sanitizer)

A lightweight, **framework-agnostic PHP library** for automatically masking sensitive data in logs. Useful for privacy compliance (e.g., GDPR, PCI DSS) and secure debugging.

- ✅ Framework-agnostic — works with any PHP project
- ✅ Format-aware — supports plain text, JSON, XML
- ✅ Regex-based masking with override support
- ✅ Ships with secure defaults (emails, passwords, API keys, etc.)
- ✅ Configurable via external `mask.php` pattern file
- ✅ No Monolog or PSR-3 required
- ✅ Modern PHP 8.0+ (typed properties, constructor promotion)

---

🚀 Installation
--------------

[](#-installation)

Install via [Composer](https://getcomposer.org/):

```
composer require ksardv/php-log-sanitizer
```

🧩 Framework Integration
-----------------------

[](#-framework-integration)

### Laravel

[](#laravel)

You can use `php-log-sanitizer` in Laravel without any special service provider or package.

#### Basic usage in a custom log processor:

[](#basic-usage-in-a-custom-log-processor)

```
use Ksardv\PhpLogSanitizer\PatternRepository;
use Ksardv\PhpLogSanitizer\Sanitizers\JsonSanitizer;

$patterns = PatternRepository::fromFile(config_path('log_mask.php'));
$sanitizer = new JsonSanitizer($patterns);

Log::info($sanitizer->sanitize(json_encode($yourPayload)));
```

📁 Examples Directory
--------------------

[](#-examples-directory)

See the [`examples/`](examples/) folder for real code:

- `text.php` – raw string sanitization
- `json.php` – structured JSON masking
- `xml.php` – XML sanitization
- `add_pattern.php` – how to define custom rules

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance52

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Total

2

Last Release

335d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56188674fde6ff11cc7d292ca56c37968c5af850ae3916a9e6642181f8c7c2b0?d=identicon)[ksardv](/maintainers/ksardv)

---

Top Contributors

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

---

Tags

logphpjsonsymfonylaravelxmlsecuritysanitizertextgdprprivacymaskMaskingpci

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ksardv-php-log-sanitizer/health.svg)

```
[![Health](https://phpackages.com/badges/ksardv-php-log-sanitizer/health.svg)](https://phpackages.com/packages/ksardv-php-log-sanitizer)
```

###  Alternatives

[hedii/laravel-gelf-logger

A Laravel package to send logs to a gelf compatible backend like graylog

1333.4M10](/packages/hedii-laravel-gelf-logger)[hedii/artisan-log-cleaner

An artisan command to clear laravel log files

4161.6k](/packages/hedii-artisan-log-cleaner)

PHPackages © 2026

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