cable8mm/db-to-markdown
Composer 安装命令:
composer create-project cable8mm/db-to-markdown
包简介
DB to markdown generator
README 文档
README
This tool generates Markdown files from a database table. It supports multiple output formats including Jekyll, Astro, Gatsby, or any custom format you create.
We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/db-to-markdown/ ❤️
Features
- Any schema can generate Markdown in any desired format
- Effortlessly incorporate your custom mapper and command
- Implement callback body and datetime functionality
- Database testing is supported
Preview
Support & Tested
| Versions | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| Available | ✅ | ✅ | ✅ | ✅ |
Installation
composer create-project cable8mm/db-to-markdown
After installation, run the init command to create the required configuration files:
php bin/console init
# Creates .env and db-to-markdown.json from their example templates
Configuration
1. Database Connection (.env)
Copy .env.example to .env and configure your database connection:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=your_database DB_USERNAME=root DB_PASSWORD=password DB_PORT=3306
If .env is not provided, SQLite is used by default with database/database.sqlite. You can customize the SQLite path by setting DB_DATABASE in your .env file. To skip database configuration entirely, leave .env out and use php bin/console seeding to seed the built-in SQLite database.
2. Table Mapping (db-to-markdown.json)
Configure your table structure and field mapping in db-to-markdown.json:
{
"table": "posts",
"author": "Your Name",
"category_labels": {
"1": "Category One",
"2": "Category Two"
},
"map": {
"title": ["title", "subtitle"],
"slug": "id",
"categories": "category_id",
"body": "content",
"published_at": "published_at"
}
}
Field Descriptions:
table: Your database table nameauthor: Default author name (used if author field is empty)category_labels: Maps category IDs to display names (optional)map.title: Column(s) for the article title (string or array)map.slug: Column for the URL slugmap.categories: Column for category mappingmap.body: Column containing HTML content (converted to Markdown)map.published_at: Published date column
Usage
Quick Start (SQLite Demo)
# Initialize configuration files php bin/console init # Seed demo data into the built-in SQLite database php bin/console seeding # Generate Markdown files php bin/console create-md # or for Jekyll format: php bin/console create-jekyll
Available Commands
# Generate standard Markdown files in dist/ php bin/console create-md # Generate Jekyll-compatible Markdown with YAML front matter php bin/console create-jekyll # Clear all generated files in dist/ php bin/console clean # Initialize configuration files from examples php bin/console init # Seed demo data for testing php bin/console seeding
Command Options
php bin/console create-md --dry-run # Shows how many files would be generated without writing them php bin/console create-md --limit=5 # Process only 5 records php bin/console create-md --limit=10 --offset=20 # Process 10 records starting from offset 20
How to Develop Custom Commands
-
Run init to create configuration files, or create them manually:
.envfor database credentialsdb-to-markdown.jsonfor table/field mapping
-
Create a mapper in
src/Mappers/to define your table field mapping (see existing examples). -
Create a format in
src/Formats/to define how output files are rendered (Markdown, Jekyll, etc.). -
Create a command in
src/Command/extendingBaseCommandor implementing your own logic. -
Register your command in
bin/console.
Formatting
composer lint # Modify all files to comply with the PSR-12. composer inspect # Inspect all files to ensure compliance with PSR-12.
Test
It uses the built-in SQLite database, not your own database. It will never cause harm to your data.
composer test
License
The DB to markdown project is open-sourced software licensed under the MIT license.
cable8mm/db-to-markdown 适用场景与选型建议
cable8mm/db-to-markdown 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「php」 「import」 「command」 「jekyll」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cable8mm/db-to-markdown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cable8mm/db-to-markdown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cable8mm/db-to-markdown 相关的其它包
同方向 / 同关键字的高下载量 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.
Parse use statements for a reflection object
Tool for copying data from a production database to a dev database. Also useful for making backups of production databases.
A fork of konnco/filament-import with support of Laravel 11 since the default importer of Filament 3 is nonsense for basic use case.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-02
