tourze/easy-admin-extra-bundle
Composer 安装命令:
composer require tourze/easy-admin-extra-bundle
包简介
EasyAdmin扩展
README 文档
README
Extension bundle for EasyAdmin, providing annotation-driven utilities and enhanced features for Symfony EasyAdmin.
Features
- AbstractCrudController: Enhanced CRUD controller with automatic field configuration, permission control, and entity copying support
- Annotation-Driven Configuration: Uses PHP 8 attributes for automatic field and filter configuration
- Field Services: Automatic field type detection and configuration based on Doctrine mapping and annotations
- Filter System: Automatic filter creation based on
@Filterableannotations - Search System: Smart search field extraction using
@Keywordannotations - Entity Copying: Built-in support for entity cloning with configurable copy rules
- Event System: Pre/post operation events for create and modify operations
- Tree Data Support: Fetch and manipulate hierarchical data structures
- Import/Export Support: Identify and process importable entity properties
- Multi-language Support: Internationalization support for labels and messages
Installation
Requirements
- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM 2.17 or 3.0+
Install via Composer
Install the package via Composer:
composer require tourze/easy-admin-extra-bundle
Configuration
Add the bundle to your config/bundles.php:
Tourze\EasyAdminExtraBundle\EasyAdminExtraBundle::class => ['all' => true],
Usage
AbstractCrudController
The main feature is the enhanced CRUD controller that automatically configures fields and filters based on annotations:
use Tourze\EasyAdminExtraBundle\Controller\AbstractCrudController; class UserCrudController extends AbstractCrudController { public static function getEntityFqcn(): string { return User::class; } }
Annotation-Driven Entity Configuration
Use PHP 8 attributes to configure your entities:
use Tourze\EasyAdminAttribute\Attribute\FormField; use Tourze\EasyAdminAttribute\Attribute\ListColumn; use Tourze\EasyAdminAttribute\Attribute\Filterable; use Tourze\EasyAdminAttribute\Attribute\Keyword; class User { #[ListColumn(order: 1)] #[FormField(order: 1)] #[Filterable] #[Keyword] private string $username; #[ListColumn(order: 2)] #[FormField(order: 2)] #[Filterable] private string $email; // Other properties... }
EntityDescriber
This service reads entity information and provides methods to get property labels, column names, and field length.
use Tourze\EasyAdminExtraBundle\Service\EntityDescriber; class MyService { public function __construct( private readonly EntityDescriber $entityDescriber, ) { } public function example(\ReflectionProperty $property): string { // Get property label return $this->entityDescriber->getPropertyLabel($property); } }
ChoiceService
Create options from enum types for use in forms.
use Tourze\EasyAdminExtraBundle\Service\ChoiceService; class MyService { public function __construct( private readonly ChoiceService $choiceService, ) { } public function example(string $enumClass): array { // Create choices from enum return iterator_to_array($this->choiceService->createChoicesFromEnum($enumClass)); } }
RepositoryTreeDataFetcher
Fetch and process tree-structured data from repositories.
use Tourze\EasyAdminExtraBundle\Service\RepositoryTreeDataFetcher; class MyTreeService { public function __construct( private readonly RepositoryTreeDataFetcher $treeFetcher, ) { } public function getTreeData(string $entityClass): array { $this->treeFetcher->setEntityClass($entityClass); return $this->treeFetcher->genTreeData(); } }
Advanced Usage
Custom Field Creation
You can extend the FieldService to create custom field types or modify existing field behavior:
use Tourze\EasyAdminExtraBundle\Service\FieldService; class CustomFieldService extends FieldService { public function createCustomField(\ReflectionProperty $property): ?FieldInterface { // Custom field creation logic return null; } }
Tree Data Manipulation
For complex tree data operations, you can extend the RepositoryTreeDataFetcher:
use Tourze\EasyAdminExtraBundle\Service\RepositoryTreeDataFetcher; class CustomTreeDataFetcher extends RepositoryTreeDataFetcher { public function customTreeProcessing(array $tree): array { // Custom tree processing logic return $tree; } }
Entity Copy Operations
Use the CopyableRepository trait for entity copying functionality:
use Tourze\EasyAdminExtraBundle\Contract\CopyableRepository; class MyEntityRepository extends ServiceEntityRepository { use CopyableRepository; // Repository implementation }
Testing
Run tests using PHPUnit:
cd packages/easy-admin-extra-bundle
composer install
php vendor/bin/phpunit
Or from the monorepo root:
php vendor/bin/phpunit packages/easy-admin-extra-bundle
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This bundle is licensed under the MIT License. See the LICENSE file for details.
tourze/easy-admin-extra-bundle 适用场景与选型建议
tourze/easy-admin-extra-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.56k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tourze/easy-admin-extra-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tourze/easy-admin-extra-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 11
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-14