tourze/doctrine-entity-markdown-bundle

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

Installs: 102

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/tourze/doctrine-entity-markdown-bundle

0.0.4 2025-05-24 17:09 UTC

This package is auto-updated.

Last update: 2025-10-31 05:19:36 UTC


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.