PHP 生成数据库的 markdown 字段说明文档,支持 mysql,postgresql[内附源码]
安装
composer require peng49/db2markdown
命令行使用
php vendor/bin/db2markdown
输入数据库的 地址(host), 端口(port) 用户名,密码,要导出的表,默认是*,生成所有表的文档,指定多个表明用逗号隔开,如: table1,table2
$ php src/bin/db2markdown
please enter the db(1 mysql,2 postgresql):
please enter the host(localhost):
please enter the port(3306): 3310
please enter username(root):
please enter password: password
please enter database: acg
please enter tables(default is *,match all table):
admin_menu successful
admin_operation_log successful
admin_permissions successful
....
E:\develop\db2markdown\db2markdown20230712091813.md is export success
导出 PostgreSQL 结构
$ php src/bin/db2markdown
please enter the db(1 mysql,2 postgresql): 3
please enter the db(1 mysql,2 postgresql): 2
please enter the host(localhost):
please enter the port(5432): 5432
please enter username(root): odoo
please enter password: password
please enter database: gocron
please enter table schema(public):
please enter tables(default is *,match all table):
task successful
task_log successful
host successful
......
E:\develop\db2markdown\db2markdown20230712092030.md is export success
代码中使用
<?php
require_once "vendor/autoload.php";
/* @var $generator \DB2Markdown\Generator\Mysql */
$generator = \DB2Markdown\Factory::getGenerator('mysql');
//mysql
$generator->setHost('localhost')
->setPort(3306)
->setDatabase('database')
->setUsername('username')
->setPassword('password')
->output("filename", "*");
源码
Github: https://github.com/peng49/db2markdown
Packagist: https://packagist.org/packages/peng49/db2markdown
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本