定制 kostasch/laravel-db-toon-schema 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kostasch/laravel-db-toon-schema

最新稳定版本:v0.1.1

Composer 安装命令:

composer require kostasch/laravel-db-toon-schema

包简介

Create a TOON schema of your DB

README 文档

README

Extract your MySQL, MariaDB, or SQLite schema into JSON and a compressed TOON text format optimized for LLM consumption.

Installation

composer require kostasch/laravel-db-toon-schema

Requirements

  • PHP ^8.2
  • Laravel ^12.0
  • MySQL, MariaDB, or SQLite

Usage

Artisan Command

# Generate using default connection
php artisan db-toon-schema

# Override connection
php artisan db-toon-schema --connection=reporting

# Override output path (relative to storage/app/private/)
php artisan db-toon-schema --output=my-schema

# Exclude specific tables or columns
php artisan db-toon-schema --exclude-tables=cache --exclude-tables=sessions
php artisan db-toon-schema --exclude-columns=created_at --exclude-columns=updated_at

# Combine options
php artisan db-toon-schema --connection=reporting --output=reporting-schema --exclude-tables=cache

Output files are saved to storage/app/private/db-toon-schema/ by default:

  • schema.json — full schema with fields and relations
  • schema.toon — compressed single-line-per-table format

Programmatic API

use Kostasch\LaravelDbToonSchema\LaravelDbToonSchema;

$schema = app(LaravelDbToonSchema::class);

$schema->toArray();   // ['schema' => [...], 'relations' => [...]]
$schema->toJson();    // JSON string
$schema->toToon();    // TOON string
$schema->save();      // writes .json + .toon to storage
$schema->save('custom-path');

Facade

use Kostasch\LaravelDbToonSchema\LaravelDbToonSchemaFacade as DbToonSchema;

DbToonSchema::toArray();
DbToonSchema::toToon();
DbToonSchema::save();

Configuration

Publish the config file:

php artisan vendor:publish --provider="Kostasch\LaravelDbToonSchema\LaravelDbToonSchemaServiceProvider" --tag=config
// config/laravel-db-toon-schema.php
return [
    'connection' => null,              // null = Laravel default connection
    'excluded_tables' => [],           // tables to always skip
    'excluded_columns' => [],          // columns to always skip
    'output_path' => 'db-toon-schema', // relative to storage/app/private/
];

Command options (--connection, --exclude-tables, --exclude-columns, --output) override config values when provided.

TOON Format

Each table is one line: table_name{field:type field:type}. Foreign keys append >ref_table.ref_col.

users{id:u64 name:str email:str}
posts{id:u64 user_id:u64>users.id title:str body:str published_at:dt}

Type Mapping

SQL Type TOON
bigint u64
int i32
mediumint i24
smallint i16
tinyint(1) b
tinyint u8
varchar, char, text, longtext str
datetime, timestamp, date dt
time time
year year
float f32
double, decimal f64
json json
enum('a','b') enum[a|b]
unknown unk

Testing

composer test
composer format

TODO

  • Add real integration tests against MySQL and MariaDB for MysqlSchemaExtractor
  • Run integration tests in CI with a MySQL/MariaDB matrix
  • Keep the current fake-based suite as the default fast test layer
  • Gate real DB integration tests behind an env flag for local development

License

MIT. See LICENSE.md.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固