tourze/doctrine-entity-routing-bundle
Composer 安装命令:
composer require tourze/doctrine-entity-routing-bundle
包简介
Symfony bundle for automatic Doctrine entity routing
README 文档
README
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
- Route Discovery: The
AttributeControllerLoaderautomatically discovers all Doctrine entities - Route Generation: For each entity table, it generates a REST endpoint
- Controller: The
EntityMetadataControllerhandles requests and returns JSON metadata - Environment Control: Routes are only generated when
ENTITY_METADATA_ROUTESis set
Architecture
- AttributeControllerLoader: Implements
RoutingAutoLoaderInterfaceto automatically generate routes - EntityMetadataController: Handles API requests and returns JSON metadata
- Integration: Works with
tourze/symfony-routing-auto-loader-bundlefor 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.
tourze/doctrine-entity-routing-bundle 适用场景与选型建议
tourze/doctrine-entity-routing-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tourze/doctrine-entity-routing-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tourze/doctrine-entity-routing-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-03