jardistools/dbschema
Composer 安装命令:
composer require jardistools/dbschema
包简介
Database schema introspection and DDL export for MySQL, MariaDB, PostgreSQL, and SQLite
关键字:
README 文档
README
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.
Features
- 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
Installation
composer require jardistools/dbschema
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 as Jardis code-generation input) $json = $exporter->toJson($tables, prettyPrint: true); file_put_contents('schema.json', $json);
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 the schema array into Jardis for code generation use JardisTools\Builder\Config\DatabaseSchema; $databaseSchema = DatabaseSchema::fromArray($schema);
Documentation
Full documentation, guides, and API reference:
docs.jardis.io/en/tools/dbschema
License
This package is licensed under the MIT License.
Jardis · Documentation · Headgent
AI-Assisted Development
This package ships with a skill for Claude Code, Cursor, Continue, and Aider. Install it in your consuming project:
composer require --dev jardis/dev-skills
More details: https://docs.jardis.io/en/skills
jardistools/dbschema 适用场景与选型建议
jardistools/dbschema 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「php」 「mysql」 「schema」 「sqlite」 「pdo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jardistools/dbschema 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jardistools/dbschema 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jardistools/dbschema 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
PHP module for MySql database
VV database abstraction layer with query builder and DB structure models
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-15