PHPackages                             jardistools/dbschema - 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. jardistools/dbschema

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

jardistools/dbschema
====================

Database schema introspection and DDL export for MySQL, MariaDB, PostgreSQL, and SQLite

v1.0.0(1w ago)012↓100%proprietaryPHPPHP &gt;=8.2CI passing

Since Mar 18Pushed 1w agoCompare

[ Source](https://github.com/jardisTools/dbSchema)[ Packagist](https://packagist.org/packages/jardistools/dbschema)[ Docs](https://github.com/jardisTools/dbschema)[ RSS](/packages/jardistools-dbschema/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Jardis DbSchema
===============

[](#jardis-dbschema)

[![Build Status](https://github.com/jardisTools/dbSchema/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisTools/dbSchema/actions/workflows/ci.yml/badge.svg)[![License: PolyForm Shield](https://camo.githubusercontent.com/d8fb46c82be4c5312bf3e372ac734dfdf6a8b328e9c2b2856af671adbb0600a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d506f6c79466f726d253230536869656c642d626c75652e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/c51bda247654363d3e30bc352674dd761a9557803a14af0226eb411d6dc0006b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d627269676874677265656e2e737667)](phpstan.neon)[![PSR-12](https://camo.githubusercontent.com/34b10db0caa29bacd49bda5c437a8de95385f036f3230b31fa605326e18da22c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5053522d2d31322d626c75652e737667)](phpcs.xml)[![Coverage](https://camo.githubusercontent.com/1571585e3d98fea87b3bff45751762259a4f746e6e3f55a661e223c45464ec15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f7665726167652d39342e32332532352d627269676874677265656e2e737667)](https://github.com/jardisTools/dbSchema)

> Part of the **[Jardis Business Platform](https://jardis.io)** — Enterprise-grade PHP components for Domain-Driven Design

Database schema introspection and DDL export. Reads table structures, columns, indexes, and foreign keys from live databases via PDO. Exports to SQL (CREATE TABLE), JSON, or PHP arrays. Dialect-aware for MySQL, MariaDB, PostgreSQL, and SQLite.

---

Features
--------

[](#features)

- **Schema Introspection** — reads tables, columns, indexes, and foreign keys from a live database
- **DDL Export** — generates `CREATE TABLE` SQL scripts with dialect-correct syntax
- **JSON Export** — structured JSON output suitable for storage, diffing, or feeding the Jardis Builder
- **Array Export** — PHP array representation for programmatic processing
- **Multi-Database** — MySQL, MariaDB, PostgreSQL, and SQLite via automatic PDO driver detection
- **Abstract Type Mapping** — `fieldType()` normalises driver-specific column types to portable abstract types
- **Field Type Normalization** — consistent column metadata regardless of database vendor

---

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

[](#installation)

```
composer require jardistools/dbschema
```

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

[](#quick-start)

```
use JardisTools\DbSchema\DbSchemaReader;
use JardisTools\DbSchema\DbSchemaExporter;

$pdo = new PDO('mysql:host=localhost;dbname=shop', 'user', 'pass');

$reader   = new DbSchemaReader($pdo);
$exporter = new DbSchemaExporter($reader);

// List all tables
$tables = $reader->tables();

// Export schema as JSON (suitable for Jardis Builder input)
$json = $exporter->toJson($tables, prettyPrint: true);
file_put_contents('schema.json', $json);
```

Advanced Usage
--------------

[](#advanced-usage)

```
use JardisTools\DbSchema\DbSchemaReader;
use JardisTools\DbSchema\DbSchemaExporter;

$pdo    = new PDO('pgsql:host=localhost;dbname=shop', 'user', 'pass');
$reader = new DbSchemaReader($pdo);

// Inspect a single table
$columns    = $reader->columns('orders');
$indexes    = $reader->indexes('orders');
$foreignKeys = $reader->foreignKeys('orders');

// Translate a driver-specific type to a portable abstract type
$abstractType = $reader->fieldType('character varying'); // → 'string'

// Export selected tables as SQL DDL
$exporter = new DbSchemaExporter($reader);
$ddl = $exporter->toSql(['orders', 'order_lines', 'customers']);
echo $ddl;
// CREATE TABLE "orders" ( ... );
// CREATE TABLE "order_lines" ( ... );

// Export as PHP array for custom processing
$schema = $exporter->toArray(['orders', 'order_lines']);
// [
//   'version'   => '1.0',
//   'generated' => '2025-01-16 10:30:00',
//   'tables'    => ['orders' => ['columns' => [...], 'indexes' => [...], 'foreignKeys' => [...]]]
// ]

// Feed directly into the Jardis Builder
use JardisTools\Builder\Config\DatabaseSchema;
$databaseSchema = DatabaseSchema::fromArray($schema);
```

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

[](#documentation)

Full documentation, guides, and API reference:

**[jardis.io/docs/tools/dbschema](https://jardis.io/docs/tools/dbschema)**

License
-------

[](#license)

This package is licensed under the [PolyForm Shield License 1.0.0](LICENSE.md). Free for all use except building competing frameworks or developer tooling.

---

**[Jardis](https://jardis.io)** · [Documentation](https://jardis.io/docs) · [Headgent](https://headgent.com)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance98

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

7d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e07a1b668e9e01ee6d1b85de7b3be1c2513f68aae9494b2011d1592104d5daa0?d=identicon)[jardis](/maintainers/jardis)

---

Top Contributors

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

---

Tags

schemadatabasepdoDomain Driven DesignHeadgentjardis

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jardistools-dbschema/health.svg)

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

###  Alternatives

[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

44231.2k4](/packages/aura-sqlschema)[thedevsaddam/laravel-schema

Display the connected database information in console.

11227.7k1](/packages/thedevsaddam-laravel-schema)

PHPackages © 2026

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