jardistools/dbschema

A flexible package for analyzing and managing database schemas (PDO-based) with support for MySQL/MariaDB, PostgreSQL, and SQLite

Installs: 21

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

pkg:composer/jardistools/dbschema

1.0.0 2026-02-25 17:38 UTC

README

Build Status License: PolyForm NC PHP Version PHPStan Level 8 PSR-4 PSR-12 Coverage

Part of the Jardis Ecosystem - A modular DDD framework for PHP

A powerful, developer-friendly PHP library for analyzing and managing database schemas. Works seamlessly with MySQL/MariaDB, PostgreSQL, and SQLite through one unified, PDO-based interface. Features automatic driver detection, normalized output structures, and complete DDL/JSON export capabilities.

Features

  • Zero Configuration - Just pass a PDO connection, automatic driver detection handles the rest
  • Universal Interface - Write once, run on MySQL, MariaDB, PostgreSQL, or SQLite
  • Complete Schema Insight - Tables, columns, indexes, foreign keys at your fingertips
  • SQL DDL Export - Generate complete database schemas with automatic dependency resolution
  • JSON/Array Export - Export schema metadata for documentation and API integration
  • Type-Safe - Built with PHP 8.2+, strict types, and PHPStan level 8

Installation

composer require jardistools/dbschema

Quick Start

use JardisTools\DbSchema\DbSchemaReader;
use JardisTools\DbSchema\DbSchemaExporter;
use PDO;

// Create PDO connection - driver auto-detected
$pdo = new PDO('mysql:host=localhost;dbname=mydb', 'user', 'pass');
$reader = new DbSchemaReader($pdo);

// Read schema information
$tables = $reader->tables();
$columns = $reader->columns('users');
$indexes = $reader->indexes('users');
$foreignKeys = $reader->foreignKeys('orders');

// Export schema
$exporter = new DbSchemaExporter($reader);
$ddl = $exporter->toSql(['users', 'orders']);             // SQL DDL
$json = $exporter->toJson(['users'], prettyPrint: true);  // JSON
$array = $exporter->toArray(['users']);                   // PHP array

Documentation

Full documentation, examples and API reference:

jardis.io/docs/tools/dbschema

Jardis Ecosystem

This package is part of the Jardis Ecosystem - a collection of modular, high-quality PHP packages designed for Domain-Driven Design.

Category Packages
Core Domain, Kernel, Data
Adapter Cache, Logger, Messaging, DbConnection
Support DotEnv, DbQuery, Validation, Factory, ClassVersion, Workflow
Tools Builder, DbSchema

Explore all packages

License

This package is licensed under the PolyForm Noncommercial License 1.0.0.

For commercial use, see COMMERCIAL.md.

Jardis Ecosystem by Headgent Development