PHPackages                             clcbws/laravel-schema-sentinel - 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. clcbws/laravel-schema-sentinel

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

clcbws/laravel-schema-sentinel
==============================

Detect and fix database schema drift in Laravel by comparing migrations with the live database state.

2.0.0(1mo ago)593.6k↓71.1%1MITPHPPHP ^8.4

Since Apr 27Pushed 1mo agoCompare

[ Source](https://github.com/ahtesham-clcbws/laravel-schema-sentinel)[ Packagist](https://packagist.org/packages/clcbws/laravel-schema-sentinel)[ RSS](/packages/clcbws-laravel-schema-sentinel/feed)WikiDiscussions main Synced 1w ago

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

Laravel Schema Sentinel
=======================

[](#laravel-schema-sentinel)

[![Latest Version on GitHub](https://camo.githubusercontent.com/53ad18f757ef5e97422014644be0091a4b6a145543e3f456c35e35c40c421aee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f616874657368616d2d636c636277732f6c61726176656c2d736368656d612d73656e74696e656c3f696e636c7564655f70726572656c6561736573267374796c653d666c61742d737175617265)](https://github.com/ahtesham-clcbws/laravel-schema-sentinel/releases)[![Total Downloads](https://camo.githubusercontent.com/0f4c32567e22f4e1a2eb555fdac8a8008a49022c93639c8078dc3db8267e710a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c636277732f6c61726176656c2d736368656d612d73656e74696e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clcbws/laravel-schema-sentinel)[![License](https://camo.githubusercontent.com/8b837155ceb1252d8770f3cce102b3e60f1774ddda8a8b10131f70d52e309fb5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616874657368616d2d636c636277732f6c61726176656c2d736368656d612d73656e74696e656c3f7374796c653d666c61742d737175617265)](https://github.com/ahtesham-clcbws/laravel-schema-sentinel/blob/main/LICENSE)

**Laravel Schema Sentinel** is a premium database schema integrity and governance suite. It detects and resolves "Schema Drift" (discrepancies between migration blueprints and the actual database state) and provides automated tools to standardize index configurations, audit content syncs, lint migration files, and reverse-engineer legacy tables.

---

📖 Table of Contents
-------------------

[](#-table-of-contents)

- [Getting Started](#-getting-started)
    - [Introduction](#introduction)
    - [Key Features](#key-features)
    - [Installation](#installation)
    - [Configuration](#configuration)
- [Artisan Commands](#-artisan-commands)
    - [Auditing Schema Drift (`schema:drift`)](#auditing-schema-drift-schemadrift)
    - [Index Standardization (`schema:standardize-indexes`)](#index-standardization-schemastandardize-indexes)
    - [Data Drift Deep Dive (`schema:data-drift`)](#data-drift-deep-dive-schemadata-drift)
    - [Legacy Database Reversing (`schema:reverse`)](#legacy-database-reversing-schemareverse)
    - [Migration File Linter (`schema:sentinel-lint`)](#migration-file-linter-schemasentinel-lint)
    - [Environment Doctor (`schema:sentinel-doctor`)](#environment-doctor-schemasentinel-doctor)
- [Programmatic API](#-programmatic-api)
    - [Drift Auditing](#drift-auditing)
    - [Parsing Schema DTOs](#parsing-schema-dtos)
    - [Index Standardization](#index-standardization)
    - [Data Drift Audits](#data-drift-audits)
    - [Programmatic Reversing](#programmatic-reversing)
    - [Livewire Component &amp; Blade UI](#livewire-component--blade-ui)
- [Legacy Compatibility](#-legacy-compatibility)
- [Changelogs](#-changelogs)

---

🚀 Getting Started
-----------------

[](#-getting-started)

### Introduction

[](#introduction)

In modern application deployment, database schemas can easily drift from migration files due to hotfixes, legacy imports, direct database edits, or faulty rollbacks. Schema Sentinel provides a total isolation simulation engine that runs migrations on a shadow database to establish the "ideal" schema, matches it against your live connection, and generates fixes automatically.

### Key Features

[](#key-features)

- 🛡️ **Deep Drift Detection**: Audits Tables, Columns, Types, Nullability, Defaults, Indexes, and Foreign Keys.
- ⚡ **Programmatic Facade**: Full API coverage for building custom monitoring dashboards.
- 📐 **Index Naming Standardizer**: Automatically validates index names against Laravel conventions.
- 🐢 **Slow Migration Audit**: Pinpoints slow migration files during simulation.
- 🔄 **Rollback Audit**: Simulates rollbacks to ensure your schema can be cleanly rolled back.
- 🌍 **Cross-Environment Sync**: Compare your schema against other environments (Staging/Production).
- 🤖 **CI/CD Ready**: Returns standard shell exit codes for pipeline validation.

### Installation

[](#installation)

Install the package via Composer:

```
composer require clcbws/laravel-schema-sentinel
```

The service provider and facade will be registered automatically.

### Configuration

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="schema-sentinel-config"
```

This creates `config/schema-sentinel.php` which allows you to define:

- **`ignore_tables`**: Array of table names to exclude from analysis (e.g., `migrations`, `telescope_entries`).
- **`migration_paths`**: Paths to your migration files (useful for modular applications).
- **`shadow_connection`**: Temporary database settings (defaults to isolated SQLite in-memory).
- **`skip_migrations`**: List of migration files to skip during shadow simulation.
- **`notifications`**: Slack and Discord webhooks for drift alerts.

---

💻 Artisan Commands
------------------

[](#-artisan-commands)

### Auditing Schema Drift (`schema:drift`)

[](#auditing-schema-drift-schemadrift)

Run the core schema audit to inspect the health of your database:

```
php artisan schema:drift
```

#### Options:

[](#options)

- **`--fix`**: Generate a new Laravel migration to align your database.
- **`--interactive`**: Confirm column changes step-by-step.
- **`--sql`**: Preview generated SQL code in dry-run mode.
- **`--strict`**: Report extra tables and columns in the live DB that are not defined in migrations.
- **`--rollback`**: Run migrations and roll them back on the shadow DB to verify reversibility.
- **`--snapshot[=latest]`**: Use a frozen JSON snapshot for audit speed.
- **`--tag=name`**: Limit audits to migrations marked with `@sentinel-tag name`.

---

### Index Standardization (`schema:standardize-indexes`)

[](#index-standardization-schemastandardize-indexes)

Inspect your database for non-standard index names and redundant indexes (e.g., column indexes already covered by composite index prefixes):

```
php artisan schema:standardize-indexes
```

#### Options:

[](#options-1)

- **`--fix`**: Generate a migration file to automatically rename deviating indexes and drop duplicate ones.

---

### Data Drift Deep Dive (`schema:data-drift`)

[](#data-drift-deep-dive-schemadata-drift)

Audit static lookup or seed tables to verify content consistency between environments:

```
php artisan schema:data-drift --compare-env=production
```

Outputs a terminal-based diff table indicating missing, extra, or mismatched rows.

---

### Legacy Database Reversing (`schema:reverse`)

[](#legacy-database-reversing-schemareverse)

Reverse-engineer a legacy database into a clean Laravel setup:

```
php artisan schema:reverse --path=./exports
```

#### Options:

[](#options-2)

- **`--models`**: Generate Eloquent Model classes with typed relationships (`belongsTo`, `hasMany`) and docblocks.
- **`--migrations`**: Generate Blueprint migration files.
- **`--seeders`**: Generate seeders filled with sample database records.
- **`--enums`**: Generate native PHP 8.4 Backed Enums linked to model casts.

---

### Migration File Linter (`schema:sentinel-lint`)

[](#migration-file-linter-schemasentinel-lint)

Audit your codebase migrations for anti-patterns that can cause drift:

```
php artisan schema:sentinel-lint
```

Scans for:

1. Raw `DB::statement` calls.
2. Hardcoded platform-specific string default dates (like `'CURRENT_TIMESTAMP'`).
3. Unsafe `Schema::drop` calls lacking `IfExists`.

---

### Environment Doctor (`schema:sentinel-doctor`)

[](#environment-doctor-schemasentinel-doctor)

Run the health advisor to verify your environment configurations (PHP version, PDO drivers, shadow connection configs):

```
php artisan schema:sentinel-doctor
```

---

### Help Guides &amp; Spelling Matcher (`schema:help`)

[](#help-guides--spelling-matcher-schemahelp)

Get detailed command help, configuration tips, and options. If you make a typo, the built-in Levenshtein suggestion engine will automatically suggest the correct command:

```
php artisan schema:help drft
```

---

🔌 Programmatic API
------------------

[](#-programmatic-api)

You can integrate Sentinel programmatically inside controllers, dashboards, or deployment hooks using the `Sentinel` facade.

### Drift Auditing

[](#drift-auditing)

```
use Sentinel\SchemaSentinel\Facades\Sentinel;

$diff = Sentinel::check(strict: true);

if ($diff->hasDifferences()) {
    // Schema has drifted
    $healthScore = $diff->getHealthScore();
    $missingTables = $diff->missingTables;
}
```

### Parsing Schema DTOs

[](#parsing-schema-dtos)

Extract structured metadata representing your database layout:

```
$tables = Sentinel::parse(); // Returns array of TableDefinition DTOs
```

### Index Standardization

[](#index-standardization)

Run the index analyzer programmatically:

```
$results = Sentinel::standardizeIndexes();
// Returns array with 'deviations' and 'redundant' indexes
```

### Data Drift Audits

[](#data-drift-audits)

Audit data consistency against a target connection:

```
$dataDrift = Sentinel::dataDrift('production');
```

### Programmatic Reversing

[](#programmatic-reversing)

Trigger the reverse engineering generator from code:

```
$results = Sentinel::reverse([
    'path' => base_path('exports'),
    'models' => true,
    'migrations' => true,
    'seeders' => false,
    'enums' => true,
]);
```

### Livewire Component &amp; Blade UI

[](#livewire-component--blade-ui)

Display database integrity metrics inside your admin templates:

```

```

Or check programmatically in Blade layouts:

```
@if(\Sentinel\SchemaSentinel\Facades\Sentinel::check()->hasDifferences())

        Warning: Database schema drift detected!

@endif
```

---

⚠️ Legacy Compatibility
-----------------------

[](#️-legacy-compatibility)

While the latest version of this package requires **Laravel 13.x** and **PHP 8.4+**, developers running **Laravel 11.x or 12.x** (with PHP 8.2 or 8.3) can use the stable **v1.6.0** release:

```
composer require clcbws/laravel-schema-sentinel:~1.6.0
```

Laravel VersionSupported PHP VersionsPackage Version**Laravel 11.x**PHP `8.2` - `8.4``~1.6.0`**Laravel 12.x**PHP `8.2` - `8.5``~1.6.0`---

📄 Changelogs
------------

[](#-changelogs)

### Latest Release: v2.0.0

[](#latest-release-v200)

- **Index Standardizer &amp; Optimizer**: Detects duplicate indexes and enforces Laravel naming conventions.
- **Data Drift Engine**: Audits static data tables across different database connections.
- **Legacy Bridge Generator**: Reverse-engineers databases into modern migrations, models with relationships, seeders, and PHP 8.4 Backed Enums.
- **PHP 8.4 / Laravel 13 Alignment**: Full type-safety compliance, strict typing enabled file-wide, and console command attributes.
- **CLI Bug Fixes**: Corrected infinite loop retry states, docs property errors, and bigInt mappings.

For past version releases, see [changelogs/v1.0.0.md](changelogs/v1.0.0.md) and [changelogs/v1.6.0.md](changelogs/v1.6.0.md).

---

🤝 Credits
---------

[](#-credits)

- **Author**: [Ahtesham](mailto:ahtesham@clcbws.com)
- **Company**: [Broadway Web Service](https://www.clcbws.com)
- **License**: [MIT License](LICENSE)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance91

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Recently: every ~11 days

Total

14

Last Release

44d ago

Major Versions

1.6.0 → 2.0.02026-06-11

PHP version history (2 changes)1.0.0-alphaPHP ^8.2

2.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17913874?v=4)[Ahtesham Abdul Aziz](/maintainers/ahtesham-clcbws)[@ahtesham-clcbws](https://github.com/ahtesham-clcbws)

---

Top Contributors

[![ahtesham-clcbws](https://avatars.githubusercontent.com/u/17913874?v=4)](https://github.com/ahtesham-clcbws "ahtesham-clcbws (21 commits)")

---

Tags

laravelmigrationlaravelschemamigrationdatabasesentineldriftclcbws

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clcbws-laravel-schema-sentinel/health.svg)

```
[![Health](https://phpackages.com/badges/clcbws-laravel-schema-sentinel/health.svg)](https://phpackages.com/packages/clcbws-laravel-schema-sentinel)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k43.2M656](/packages/spatie-laravel-medialibrary)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

463.0k](/packages/itpathsolutions-dbstan)

PHPackages © 2026

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