定制 pongee/database-schema-visualization 二次开发

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

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

pongee/database-schema-visualization

最新稳定版本:4.0.0

Composer 安装命令:

composer require pongee/database-schema-visualization

包简介

Database schema visualization

README 文档

README

Latest Stable Version Minimum PHP Version License GitHub code size in bytes

Project goal

The aim of this project is to generate database documentation from sql schema.

Supported databases

  • MySQL
  • MariaDB
  • Apache Cassandra (Basics)

Supported Output formats

  • PNG, SVG image
  • Plantuml raw text
  • Json

Pre Installation

Installation

$ composer require pongee/database-schema-visualization
or add it the your composer.json and make a composer update pongee/database-schema-visualization.

Usage

In console

PNG export

$  php ./database-schema-visualization mysql:image ./example/schema/sakila.sql > ./example/img/sakila.png
$  php ./database-schema-visualization mysql:image --type png ./example/schema/sakila.sql > ./example/img/sakila.png

Output: Example output

SVG export

$  php ./database-schema-visualization mysql:image --type svg ./example/schema/sakila.sql > ./example/img/sakila.svg

Json export

$  php ./database-schema-visualization mysql:json ./example/schema/sakila.sql

Plantuml export

$  php ./database-schema-visualization mysql:plantuml ./example/schema/sakila.sql

PHP

Png export

<?php declare(strict_types=1);

use Pongee\DatabaseSchemaVisualization\DataObject\Sql\Database\Connection\ConnectionCollection;
use Pongee\DatabaseSchemaVisualization\Export\Plantuml;
use Pongee\DatabaseSchemaVisualization\Generator\ImageGenerator;
use Pongee\DatabaseSchemaVisualization\Parser\MysqlParser;

include __DIR__ . '/../../vendor/autoload.php';

$sqlSchema = '
  CREATE TABLE IF NOT EXISTS `foo` (
    `id` INT(10) UNSIGNED NOT NULL COMMENT "The id"
   ) ENGINE=innodb DEFAULT CHARSET=utf8;
';

$sqlParser                = new MysqlParser();
// $cqlParser                = new \Pongee\DatabaseSchemaVisualization\Parser\CassandraParser();
$plantumlExport             = new Plantuml(file_get_contents(__DIR__ . '/../../src/Template/Plantuml/v1.twig'));
$forcedConnectionCollection = new ConnectionCollection();
$imageGenerator             = new ImageGenerator(
    'png',
    __DIR__ . '/../../bin/plantuml.jar',
    __DIR__ . '/../../tmp/'
);

$schema = $sqlParser->run($sqlSchema, $forcedConnectionCollection);

print $imageGenerator->generate($plantumlExport->export($schema));

Json export

<?php declare(strict_types=1);

use Pongee\DatabaseSchemaVisualization\DataObject\Sql\Database\Connection\ConnectionCollection;
use Pongee\DatabaseSchemaVisualization\Export\Json;
use Pongee\DatabaseSchemaVisualization\Parser\MysqlParser;

include './vendor/autoload.php';

$sqlSchema = '
  CREATE TABLE IF NOT EXISTS `foo` (
    `id` INT(10) UNSIGNED NOT NULL COMMENT "The id"
   ) ENGINE=innodb DEFAULT CHARSET=utf8;
';

$mysqlParser                = new MysqlParser();
$jsonExport                 = new Json();
$forcedConnectionCollection = new ConnectionCollection();

$schema = $mysqlParser->run($sqlSchema, $forcedConnectionCollection);

print $jsonExport->export($schema);
This will generate:
{
    "tables": {
        "foo": {
            "columns": [
                {
                    "name": "id",
                    "type": "INT",
                    "typeParameters": [
                        "10"
                    ],
                    "otherParameters": "UNSIGNED NOT NULL",
                    "comment": "The id"
                }
            ],
            "indexs": {
                "simple": [],
                "spatial": [],
                "fulltext": [],
                "unique": []
            },
            "primaryKey": []
        }
    },
    "connections": []
}
    

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固