PHPackages                             zuqongtech/laravel-db-introspection - 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. zuqongtech/laravel-db-introspection

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

zuqongtech/laravel-db-introspection
===================================

A Laravel package for automatic database introspection and model generation supporting MySQL, PostgreSQL, SQL Server, and more.

1.0.1(6mo ago)049MITPHPPHP ^8.2CI failing

Since Nov 12Pushed 3mo agoCompare

[ Source](https://github.com/gideonzozingao/laravel-db-introspection)[ Packagist](https://packagist.org/packages/zuqongtech/laravel-db-introspection)[ RSS](/packages/zuqongtech-laravel-db-introspection/feed)WikiDiscussions main Synced 1mo ago

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

📦 Laravel DB Introspection
==========================

[](#-laravel-db-introspection)

[![Packagist Version](https://camo.githubusercontent.com/ee92c05368388d8ca79d2be4cca6d66cbd0c5e53affcab23e1c2b413f96b033b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a75716f6e67746563682f6c61726176656c2d64622d696e74726f7370656374696f6e2e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/zuqongtech/laravel-db-introspection)[![License](https://camo.githubusercontent.com/37e87851b1f8d3ed802484d99506b64290d4caab17055b02845d4103ba7d7296/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f676964656f6e7a6f7a696e67616f2f6c61726176656c2d64622d696e74726f7370656374696f6e2e7376673f7374796c653d666f722d7468652d6261646765)](LICENSE)[![Build Status](https://camo.githubusercontent.com/c495d52fad35466e74fd2756af3f372e3e8c0f6a148c2436eb87cd190a6984c4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a75716f6e67746563682f6c61726176656c2d64622d696e74726f7370656374696f6e2f74657374732e796d6c3f7374796c653d666f722d7468652d6261646765)](https://github.com/gideonzozingao/laravel-db-introspection/actions)[![Laravel](https://camo.githubusercontent.com/9b55783b5ef75fbb4fa0953845a418da290736f80131ecb4de0a875446bb91cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825323025374325323031312e782d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/d42f00a0774ba79b377dcc0373c3862649590e18801c3f009c6a5c2c83dd3db7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net)

---

> **Zuqongtech/Laravel-DB-Introspection** — a Laravel package for automatic **database introspection**, model discovery, constraint analysis, and **Eloquent model generation**.

It scans your connected database, analyzes schema metadata, and **automatically generates robust Eloquent models** — complete with relationships, indexes, PHPDoc, and constraints.

Perfect for teams working with **enterprise databases**, existing legacy schemas, or large systems that need instant, accurate Eloquent models.

---

🧠 Features
==========

[](#-features)

### Core Features

[](#core-features)

✔ Multi-database engine support ✔ Auto-generates Eloquent models ✔ Relationship detection (FK-based) ✔ Inverse relationships (optional) ✔ Constraint &amp; index analysis ✔ Optional validation of keys and schema integrity ✔ Full PHPDoc generation for IDEs ✔ Dry-run preview mode ✔ Backups of existing models ✔ Highly configurable paths, namespaces &amp; filters

---

🚀 Installation
==============

[](#-installation)

```
composer require zuqongtech/laravel-db-introspection
```

For local package development:

```
git clone https://github.com/zuqongtech/laravel-db-introspection.git
cd laravel-db-introspection
composer install
```

---

⚙️ Configuration
================

[](#️-configuration)

Publish the config file:

```
php artisan vendor:publish --provider="Zuqongtech\LaravelDbIntrospection\LaravelDbIntrospectionServiceProvider" --tag=config
```

Generated file:

```
config/zt-introspection.php

```

Basic config:

```
return [
    'output_path' => app_path('Models'),
    'namespace'   => 'App\\Models',
    'ignore_tables' => [],
];
```

---

🧭 Usage
=======

[](#-usage)

Run the command:

```
php artisan zt:generate-models
```

---

🔧 All Available Flags (Full Documentation)
==========================================

[](#-all-available-flags-full-documentation)

Below is the full documentation of **all flags** from the command signature:

---

🎯 Model Generation Flags
------------------------

[](#-model-generation-flags)

FlagDescriptionExample`--force`Overwrite existing models`--force``--backup`Backup existing models before overwriting`--backup``--dry-run`Preview actions without writing files`--dry-run``--namespace=`Set the namespace of generated models`--namespace="App\\Domain\\Models"``--path=`Base folder for generated models`--path=modules/Core`---

🎛 Table Selection &amp; Filtering
---------------------------------

[](#-table-selection--filtering)

FlagDescriptionExample`--tables=*`Only generate models for specific tables`--tables=users --tables=orders``--ignore=*`Skip listed tables`--ignore=migrations``--connection=`Specify database connection`--connection=pgsql`---

📚 Documentation &amp; Metadata Flags
------------------------------------

[](#-documentation--metadata-flags)

FlagDescriptionExample`--with-phpdoc`Include PHPDoc blocks for IDE autocomplete`--with-phpdoc``--with-constraints`Include constraints in model comments`--with-constraints`---

🔗 Relationship Flags
--------------------

[](#-relationship-flags)

FlagDescriptionExample`--with-inverse`Generate inverse relations (`hasMany`, `hasOne`)`--with-inverse``--validate-fk`Validate all foreign key references`--validate-fk`---

🧱 Constraint &amp; Integrity Analysis
-------------------------------------

[](#-constraint--integrity-analysis)

FlagDescriptionExample`--analyze-constraints`Display constraint summary (PKs, FKs, indexes)`--analyze-constraints``--validate-fk`Validate FK integrity across tables`--validate-fk``--show-recommendations`Show optimization suggestions`--show-recommendations`---

🔥 Combined Example Commands
===========================

[](#-combined-example-commands)

### Generate everything with PHPDoc + inverse relationships:

[](#generate-everything-with-phpdoc--inverse-relationships)

```
php artisan zt:generate-models --with-phpdoc --with-inverse
```

### Only generate the `users` and `orders` models:

[](#only-generate-the-users-and-orders-models)

```
php artisan zt:generate-models --tables=users --tables=orders
```

### Validate foreign keys + analyze constraints:

[](#validate-foreign-keys--analyze-constraints)

```
php artisan zt:generate-models --validate-fk --analyze-constraints
```

### Full analysis + recommendations:

[](#full-analysis--recommendations)

```
php artisan zt:generate-models --analyze-constraints --show-recommendations
```

### Run without creating any files (dry-run):

[](#run-without-creating-any-files-dry-run)

```
php artisan zt:generate-models --dry-run
```

---

📂 Example Output
================

[](#-example-output)

Generated files:

```
app/Models/User.php
app/Models/Order.php
app/Models/Product.php

```

Each contains:

- `$table`
- `$fillable`
- `$primaryKey` or composite keys
- Soft delete detection
- Timestamp detection
- Relationships (FK + inverse)
- Optional PHPDoc
- Optional constraint notes

---

💡 Example Generated Model
=========================

[](#-example-generated-model)

```
