Part of Jardis — the Domain-Driven Design platform for PHP. You model your domain; Jardis generates the production-ready hexagonal code (DTOs, Command/Query handlers, repositories, persistence). This package is part of the open-source foundation that generated code runs on.
Database schema analysis for PHP — introspects and exports the structure of live databases via PDO. Reads tables, columns, indexes, and foreign keys, then emits SQL (CREATE TABLE), JSON, or PHP arrays for schema import, diffing, or as the schema on-ramp for hexagonal code generation. Dialect-aware for MySQL, MariaDB, PostgreSQL, and SQLite.
- Schema Introspection — reads tables, columns, indexes, and foreign keys from a live database
- DDL Export — generates
CREATE TABLESQL scripts with dialect-correct syntax - JSON Export — structured JSON output suitable for storage, diffing, or feeding Jardis code generation
- 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
composer require jardistools/dbschemause 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 as Jardis code-generation input)
$json = $exporter->toJson($tables, prettyPrint: true);
file_put_contents('schema.json', $json);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 the schema array into Jardis for code generation
use JardisTools\Builder\Config\DatabaseSchema;
$databaseSchema = DatabaseSchema::fromArray($schema);Full documentation, guides, and API reference:
docs.jardis.io/en/tools/dbschema
This package is licensed under the MIT License.
Jardis · Documentation · Headgent
Dieses Package liefert einen Skill für Claude Code, Cursor, Continue und Aider mit. Installation im Konsumentenprojekt:
composer require --dev jardis/dev-skillsMehr Details: https://docs.jardis.io/en/skills