承接 tourze/doctrine-entity-routing-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tourze/doctrine-entity-routing-bundle

最新稳定版本:0.1.0

Composer 安装命令:

composer require tourze/doctrine-entity-routing-bundle

包简介

Symfony bundle for automatic Doctrine entity routing

README 文档

README

English | 中文

Latest Version PHP Version Require License Total Downloads Code Coverage

A Symfony Bundle that automatically generates REST API routes for Doctrine entity metadata inspection.

Features

  • Automatically discovers all Doctrine entities in your application
  • Generates REST API endpoints for entity metadata inspection
  • Provides JSON responses with table structure information
  • Supports environment-based route generation control
  • Includes comprehensive test coverage

Installation

composer require tourze/doctrine-entity-routing-bundle

Configuration

Register the Bundle

Add the bundle to your config/bundles.php:

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

Enable Route Generation

Set the environment variable to enable route generation:

# .env
ENTITY_METADATA_ROUTES=enabled

Add Route Loader

Add the route loader to your config/routes.yaml:

entity_routes:
    resource: .
    type: entity_route

Usage

Once configured, the bundle will automatically generate routes for all your Doctrine entities.

API Endpoints

For each entity table, the bundle generates:

GET /entity/desc/{table_name}

Example Response

{
  "table": "user",
  "columns": [
    {
      "field": "id",
      "type": "integer",
      "length": null,
      "nullable": false
    },
    {
      "field": "email",
      "type": "string",
      "length": 255,
      "nullable": false
    },
    {
      "field": "name",
      "type": "string",
      "length": 100,
      "nullable": true
    }
  ]
}

Error Response

If the table is not found:

{
  "error": "Table not found"
}

Requirements

  • PHP 8.1+
  • Symfony 6.4+
  • Doctrine ORM 3.0+
  • Doctrine Bundle 2.13+

Dependencies

  • tourze/symfony-routing-auto-loader-bundle - For automatic route loading
  • Standard Symfony and Doctrine components

Testing

Run the test suite:

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

Run PHPStan analysis:

php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/doctrine-entity-routing-bundle

How It Works

  1. Route Discovery: The AttributeControllerLoader automatically discovers all Doctrine entities
  2. Route Generation: For each entity table, it generates a REST endpoint
  3. Controller: The EntityMetadataController handles requests and returns JSON metadata
  4. Environment Control: Routes are only generated when ENTITY_METADATA_ROUTES is set

Architecture

  • AttributeControllerLoader: Implements RoutingAutoLoaderInterface to automatically generate routes
  • EntityMetadataController: Handles API requests and returns JSON metadata
  • Integration: Works with tourze/symfony-routing-auto-loader-bundle for seamless route loading

Contributing

Please see CONTRIBUTING.md for details on how to contribute to this project.

Changelog

Please see CHANGELOG.md for details on what has changed recently.

License

The MIT License (MIT). Please see LICENSE file for more information.

统计信息

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

GitHub 信息

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

其他信息

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