定制 tourze/doctrine-entity-markdown-bundle 二次开发

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

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

tourze/doctrine-entity-markdown-bundle

最新稳定版本:1.0.1

Composer 安装命令:

composer require tourze/doctrine-entity-markdown-bundle

包简介

基于 Doctrine 实体生成数据库字典的 Symfony Bundle

README 文档

README

English | 中文

Latest Version PHP Version License Build Status Code Coverage

A Symfony Bundle for generating Markdown format database dictionaries from Doctrine entities.

Features

  • Generate complete database table listings
  • Generate detailed field information for each table including field types, length, nullable status, default values, comments, etc.
  • Handle associations between entities
  • Support MCP (Model Context Protocol) tool integration for AI assistants

Installation

composer require tourze/doctrine-entity-markdown-bundle

Configuration

Add the bundle to your config/bundles.php:

return [
    // ...
    Tourze\DoctrineEntityMarkdownBundle\DoctrineEntityMarkdownBundle::class => ['all' => true],
];

Requirements

This package requires the following components:

  • PHP ^8.1
  • Symfony ^7.3
  • Doctrine ORM ^3.0
  • Doctrine Bundle ^2.13

Quick Start

Command Line Usage

Generate Markdown format database dictionary using the following command:

bin/console doctrine:generate:markdown

Usage in Code

use Tourze\DoctrineEntityMarkdownBundle\Service\EntityServiceInterface;

class YourController
{
    public function __construct(
        private readonly EntityServiceInterface $entityService,
    ) {
    }
    
    public function generateDictionary()
    {
        // Get all table names
        $tableList = $this->entityService->getAllTableNames();
        
        // Get metadata for a specific entity
        $userMetadata = $this->entityService->getEntityMetadata('App\Entity\User');
        
        // Get metadata for all entities
        $allMetadata = $this->entityService->getAllEntitiesMetadata();
        
        // Generate complete database dictionary
        $fullMarkdown = $this->entityService->generateDatabaseMarkdown();
    }
}

Advanced Usage

MCP Tool Integration

This package provides MCP (Model Context Protocol) tools for AI assistant integration:

use Tourze\DoctrineEntityMarkdownBundle\MCP\Tool\GetDatabaseDictionary;

// Get database dictionary through MCP
$tool = new GetDatabaseDictionary($entityService);
$result = $tool->execute();

Custom Output Format

You can extend the EntityService class to customize the output format:

class CustomEntityService extends EntityService
{
    public function generateCustomMarkdown(): string
    {
        // Custom generation logic
        return $this->generateDatabaseMarkdown();
    }
}

Testing

Run unit tests:

./vendor/bin/phpunit packages/doctrine-entity-markdown-bundle/tests

Contributing

Please feel free to submit issues and pull requests. Make sure to follow the existing code style and add tests for any new functionality.

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-29