PHPackages                             itpathsolutions/dbstan - 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. itpathsolutions/dbstan

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

itpathsolutions/dbstan
======================

Database Standardization and Analysis Tool for Laravel

1.0.8(2mo ago)492.8k2MITPHPPHP ^8.1|^8.2|^8.3|^8.4|^8.5

Since Feb 13Pushed 2mo agoCompare

[ Source](https://github.com/dhanikk/dbstan)[ Packagist](https://packagist.org/packages/itpathsolutions/dbstan)[ RSS](/packages/itpathsolutions-dbstan/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (12)Versions (9)Used By (0)

DBStan - Laravel Database Schema Analysis &amp; Insights
========================================================

[](#dbstan---laravel-database-schema-analysis--insights)

[![Latest Version](https://camo.githubusercontent.com/ca9fb0124f046af12f85b258de0acdae018d54d6042f7a4aed09bf18f5f18791/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f697470617468736f6c7574696f6e732f64627374616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itpathsolutions/dbstan)![Tests](https://camo.githubusercontent.com/24124f835ef652afe6ea3c83413fdef34c14c3cc8e3674e294cf6bcc53718ed9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e3f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/af9ddcafe77263a431072a7cedada67548fc7e95559fba5481c3d90da515450e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f697470617468736f6c7574696f6e732f64627374616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itpathsolutions/dbstan)[![License](https://camo.githubusercontent.com/ac049ef4e7a0b7196b09add6ac2d4f180e544c0ac779c2b2ac2fd2723a209579/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75653f7374796c653d666c61742d737175617265)](LICENSE)![PHP Version](https://camo.githubusercontent.com/bf4bda9d4d0ed45dda848717371d8b1854e1002a3d0bf0990030ff55b143d5c9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c75653f7374796c653d666c61742d737175617265)![Laravel](https://camo.githubusercontent.com/a3178132685e5cd3d20f913076e5224e4f997bbcf5b66f31b9399b5bbf9e8824/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d39253230746f25323031332d7265643f7374796c653d666c61742d737175617265)

The **DBStan** package provides detailed analysis and insights into your database schema for Laravel applications. It helps identify structural issues, missing indexes, normalization problems, nullable column risks, foreign key inconsistencies, and performance concerns.

It is an essential tool for **debugging, optimizing, reviewing, and maintaining a healthy database architecture** in Laravel projects.

Current release: **v1.0.8** with **MySQL and PostgreSQL** support.

---

**Important Notice: Configure Database Before Using This Package**
------------------------------------------------------------------

[](#important-notice-configure-database-before-using-this-package)

Before using this package, ensure your database connection is properly configured in your Laravel application.

If the database is not configured correctly, DBStan will not be able to analyze your schema.

Make sure your `.env` file contains valid database credentials.

---

**Security Warning**
--------------------

[](#security-warning)

This package exposes detailed database schema analysis.
It is intended for **admin and development use only**.

Do **NOT** expose this tool publicly in production without proper access restrictions, as schema details may reveal sensitive structural information.

---

 [\#Laravel](https://packagist.org/search/?tags=laravel) [\#Database](https://packagist.org/search/?tags=database) [\#Schema](https://packagist.org/search/?tags=schema) [\#PHP](https://packagist.org/search/?tags=php) [\#Performance](https://packagist.org/search/?tags=performance) [\#Optimization](https://packagist.org/search/?tags=optimization) [\#Analysis](https://packagist.org/search/?tags=analysis)

---

Documentation
-------------

[](#documentation)

- [Features](#features)
- [Supported Versions](#supported-versions)
- [Installation](#installation)
- [Commands](#commands)
    - [Vendor Publish](#vendor-publish)
    - [Run Analysis for Production](#run-analysis-for-production)
- [Output Categories](#output-categories)
- [Environment Configuration](#environment-configuration)
- [FAQs](#faqs)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [License](#license)

---

Video
-----

[](#video)

-

---

**Features**
------------

[](#features)

- Analyze full database schema structure
- Detect missing indexes on foreign keys and log tables
- Identify nullable column overuse and high NULL value ratios
- Detect normalization and integrity issues (duplicate rows, orphan risks, improper foreign key naming)
- Audit trail checks (created\_by, updated\_by, deleted\_by columns)
- Detect repeated common fields across tables
- Identify tables with too many columns or wide VARCHARs
- Detect tables missing a PRIMARY KEY
- Highlight performance risks (large TEXT columns, JSON overuse, unbounded growth, table size)
- Detect storage engine issues (non-InnoDB tables and mixed engines)
- Detect charset/collation mismatches (utf8 vs utf8mb4 and inconsistent collations)
- Analyze auto-increment overflow risk on high-growth tables
- Identify low-cardinality indexes that may be ineffective
- Recommend composite indexes for common filtering patterns (e.g., user\_id + status)
- Analyze overall database size and table storage dominance
- Detect improper pivot table structures
- Identify enum and boolean overuse
- Detect mixed domain columns (e.g., info/data/details in varchar)
- Check for missing soft deletes and timestamps
- Detect datatype mismatch using column-name heuristics (price/amount, email, \**at, is*/has\_)
- Detect status columns missing indexes
- Detect polymorphic relation overuse and missing indexes
- Lightweight and optimized for fast schema scanning
- Supports MySQL and PostgreSQL database drivers
- Supports Laravel 9, 10, 11, 12, and 13 with PHP 8.1+ compatibility
- CLI-based analysis with structured categorized output

---

**Supported Versions**
----------------------

[](#supported-versions)

- **PHP:** ^8.1 | ^8.2 | ^8.3 | ^8.4 | ^8.5
- **Illuminate Support:** ^9.0 | ^10.0 | ^11.0 | ^12.0 | ^13.0
- **Database:** MySQL (5.7+ / 8.0+ recommended), PostgreSQL

---

**Installation**
----------------

[](#installation)

To install the package, run:

```
composer require itpathsolutions/dbstan
```

Copy Install Command

---

**Commands**
------------

[](#commands)

### **Vendor Publish**

[](#vendor-publish)

After installing the package, you may publish the configuration file using:

```
php artisan vendor:publish --tag=dbstan-config
```

Copy Vendor Publish Command

This will create the configuration file at:

```
config/dbstan.php
```

You can customize thresholds like:

- Maximum columns per table
- Maximum VARCHAR length
- JSON column limits
- Large table size threshold
- Total database size threshold
- Unusually large table ratio threshold
- Table dominance ratio threshold
- Nullable ratio threshold
- Auto-increment risk thresholds
- Index cardinality thresholds

---

### **Run Analysis for Production**

[](#run-analysis-for-production)

To analyze your database schema:

```
php artisan dbstan:analyze
```

or

```
http://127.0.0.1:8000/dbstan
```

Both options scan your entire database and display categorized results in the browser or terminal.

---

**Output Categories**
---------------------

[](#output-categories)

DBStan organizes its findings into four main categories:

### 1. **Structure Issues**

[](#1-structure-issues)

- Tables with too many columns
- Wide VARCHAR fields
- Missing timestamps or soft deletes
- Boolean and enum overuse
- Nullable column overuse
- Large TEXT columns
- Data type appropriateness
- Missing primary key detection
- Mixed domain columns
- Repeated common fields across tables
- Pivot table structure issues

### 2. **Integrity Issues**

[](#2-integrity-issues)

- Duplicate rows detection
- Foreign key naming inconsistencies
- Cascading action problems
- Possible orphan risks
- Unique constraint violations

### 3. **Performance Issues**

[](#3-performance-issues)

- Missing indexes on foreign keys
- Missing indexes on log tables
- Missing indexes on status columns
- High NULL value ratios
- Table size analysis
- Database size threshold analysis
- Unusually large table and table-dominance detection
- Auto-increment overflow and growth risk analysis
- Low-cardinality/useless index detection
- High-cardinality index misuse heuristics (standalone status/flag indexes)
- Composite index recommendations (user\_id + status/state)
- Unbounded growth risks

### 4. **Architecture Issues**

[](#4-architecture-issues)

- Audit trail implementation (created\_by, updated\_by, deleted\_by)
- JSON column overuse
- Polymorphic relation overuse
- Storage engine consistency (InnoDB and mixed-engine detection)
- Charset and collation consistency checks

---

**Environment Configuration**
-----------------------------

[](#environment-configuration)

Ensure your `.env` file contains:

```
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
```

For PostgreSQL, use:

```
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
```

After updating configuration:

```
php artisan config:clear
```

---

**FAQs**
--------

[](#faqs)

### 1. What does this package do?

[](#1-what-does-this-package-do)

DBStan analyzes your Laravel database schema and detects structural, normalization, and performance issues.

---

### 2. Does it modify my database?

[](#2-does-it-modify-my-database)

No. DBStan is completely read-only.
It does **NOT** make any changes to your database.

---

### 3. Is it safe for production?

[](#3-is-it-safe-for-production)

Yes, but it is recommended to use it in development or staging environments.
Avoid exposing schema analysis publicly.

---

**Contributing**
----------------

[](#contributing)

Contributions are welcome!

If you'd like to contribute:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/your-feature`)
3. Commit your changes (`git commit -am 'Add new feature'`)
4. Push to the branch (`git push origin feature/your-feature`)
5. Open a Pull Request

Please ensure:

- Your code follows PSR-12 coding standards
- All tests pass before submitting
- You include tests for new features

For major changes, please open an issue first to discuss what you would like to change.

---

**Security Vulnerabilities**
----------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within DBStan, please send an email to .

All security vulnerabilities will be promptly addressed.

For more details, see our [Security Policy](SECURITY.md).

---

**License**
-----------

[](#license)

DBStan is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance84

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~7 days

Total

8

Last Release

88d ago

PHP version history (3 changes)1.0.1PHP ^8.1|^8.2|^8.3

1.0.3PHP ^8.1|^8.2|^8.3|^8.4

1.0.6PHP ^8.1|^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/74d7fbd5e506bbbd7ab765e785d26a663744a74347fe6b0c855c3f55577ed5d4?d=identicon)[dhanikk\_itpath](/maintainers/dhanikk_itpath)

---

Top Contributors

[![dev-archana-soni](https://avatars.githubusercontent.com/u/94445886?v=4)](https://github.com/dev-archana-soni "dev-archana-soni (18 commits)")[![dhanikk](https://avatars.githubusercontent.com/u/112705004?v=4)](https://github.com/dhanikk "dhanikk (4 commits)")[![sharafat](https://avatars.githubusercontent.com/u/810435?v=4)](https://github.com/sharafat "sharafat (1 commits)")[![vidhi-nirmal71](https://avatars.githubusercontent.com/u/125467384?v=4)](https://github.com/vidhi-nirmal71 "vidhi-nirmal71 (1 commits)")

---

Tags

phplaravelschemadatabaseperformanceanalysisitpathsolutionsdbstan

### Embed Badge

![Health badge](/badges/itpathsolutions-dbstan/health.svg)

```
[![Health](https://phpackages.com/badges/itpathsolutions-dbstan/health.svg)](https://phpackages.com/packages/itpathsolutions-dbstan)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k43.2M630](/packages/spatie-laravel-medialibrary)[larastan/larastan

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

6.5k55.4M8.4k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M193](/packages/laravel-ai)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[calebdw/larastan

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

15118.7k4](/packages/calebdw-larastan)

PHPackages © 2026

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