PHPackages                             laravelldone/db-cleaner - 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. [Database &amp; ORM](/categories/database)
4. /
5. laravelldone/db-cleaner

ActiveLibrary[Database &amp; ORM](/categories/database)

laravelldone/db-cleaner
=======================

Scan database tables for data quality issues (duplicates, typos, whitespace, casing) with a Livewire dashboard and REST API

v1.0.4(3mo ago)03MITPHPPHP ^8.2

Since Mar 19Pushed 3mo agoCompare

[ Source](https://github.com/neon2027/db-cleaner)[ Packagist](https://packagist.org/packages/laravelldone/db-cleaner)[ RSS](/packages/laravelldone-db-cleaner/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (12)Versions (6)Used By (0)

DB Cleaner
==========

[](#db-cleaner)

A Laravel package that scans your database tables for data quality issues and helps you fix them.

The Problem
-----------

[](#the-problem)

Real-world databases accumulate noise over time:

- `"john doe"`, `"John Doe"`, `"JOHN DOE"` — same person, three records
- `" Engineering "`, `"engineering"` — same department, inconsistent casing
- `"Managment"`, `"Management"` — typo that slipped past validation
- `" alice@example.com"` — leading space breaking lookups

These issues corrupt reports, break deduplication logic, and make search unreliable. DB Cleaner detects and fixes them without guesswork.

What It Does
------------

[](#what-it-does)

IssueHow DetectedExact duplicates`GROUP BY col HAVING COUNT(*) > 1`Fuzzy duplicatesLevenshtein distance (configurable threshold)Soundex matches`soundex()` groupingLeading/trailing whitespace`col != TRIM(col)`Double spaces / tabsSQL `LIKE` patternsCasing inconsistencies`GROUP BY LOWER(col) HAVING COUNT(DISTINCT col) > 1`Typos`similar_text()` against high-frequency valuesEach column gets a **quality score (0–100)** and a **letter grade (A–F)**. Scores are stored so you can track improvement over time.

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

[](#installation)

```
composer require laravelldone/db-cleaner
php artisan vendor:publish --provider="Laravelldone\DbCleaner\DbCleanerServiceProvider"
php artisan migrate
```

Quick Start
-----------

[](#quick-start)

```
# Scan all tables and see what's wrong
php artisan db-cleaner:scan

# Preview what cleaning would do — no data is touched
php artisan db-cleaner:clean users --column=name --type=whitespace --dry-run

# Apply the fix
php artisan db-cleaner:clean users --column=name --type=whitespace
```

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

[](#configuration)

`config/db-cleaner.php` — the key options:

```
// Limit to specific tables and columns (empty = scan everything)
'tables' => [
    'users'    => ['name', 'email'],
    'products',
],

// Tables never scanned
'exclude_tables' => ['migrations', 'jobs', 'sessions'],

// Fuzzy duplicate sensitivity (lower = stricter)
'duplicates' => ['fuzzy_threshold' => 2],

// Typo detection similarity (0–100, higher = stricter)
'typos' => ['similarity_threshold' => 85],
```

CLI
---

[](#cli)

```
# Scan one table, specific columns
php artisan db-cleaner:scan --table=users --columns=name,email

# View scan history
php artisan db-cleaner:report --table=users --format=json

# Clean types: whitespace | casing | duplicate
php artisan db-cleaner:clean users --column=name --type=casing --dry-run
php artisan db-cleaner:clean users --column=name --type=casing --force
```

PHP / Facade
------------

[](#php--facade)

```
use Laravelldone\DbCleaner\Facades\DbCleaner;

$analysis = DbCleaner::scan('users');

$analysis->qualityScore;      // 73.4
$analysis->grade;             // C
$analysis->totalIssueCount(); // 28

// Preview before touching anything
$actions = DbCleaner::previewClean('users', 'name', 'whitespace');

// Apply (confirm required — no accidental changes)
DbCleaner::clean('users', 'name', 'whitespace', confirm: true);
```

REST API
--------

[](#rest-api)

```
GET  /api/db-cleaner/status              — overall DB health
GET  /api/db-cleaner/tables              — all tables with scores
GET  /api/db-cleaner/tables/{table}      — detailed column breakdown
POST /api/db-cleaner/tables/{table}/scan — trigger a scan
GET  /api/db-cleaner/history             — score trends over time
POST /api/db-cleaner/clean/preview       — preview cleaning actions
POST /api/db-cleaner/clean/apply         — apply (requires "confirm": true)

```

Protect the API with a token in `.env`:

```
DB_CLEANER_API_TOKEN=your-secret

```

Dashboard
---------

[](#dashboard)

Visit `/db-cleaner` for a Livewire dashboard with:

- Quality scores and grades per table
- Issue breakdown chart (Chart.js, no npm required)
- Score trend over time
- Run scans and apply cleaning from the browser

Safety
------

[](#safety)

- **No data is ever modified without explicit confirmation** — `--dry-run` in CLI, `"confirm": true` in the API, `confirm: true` in PHP
- All cleaning runs inside a `DB::transaction()`
- Fuzzy analysis is skipped on tables over 5,000 rows by default (`max_rows_for_fuzzy`) to prevent memory issues

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

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12
- Livewire 3 or 4

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance82

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Total

5

Last Release

97d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/33a01c3423be5158fc89f506a57bb31743896332069195d614e205ee4d42a073?d=identicon)[neon2027](/maintainers/neon2027)

---

Top Contributors

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

---

Tags

data-qualitydatabaselaravellivewirephplaraveldatabaselivewirecleanerdata qualityduplicates

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/laravelldone-db-cleaner/health.svg)

```
[![Health](https://phpackages.com/badges/laravelldone-db-cleaner/health.svg)](https://phpackages.com/packages/laravelldone-db-cleaner)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M152](/packages/spatie-laravel-health)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

438834.4k1](/packages/clickbar-laravel-magellan)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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