tourze/easy-admin-attribute 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tourze/easy-admin-attribute

Composer 安装命令:

composer require tourze/easy-admin-attribute

包简介

EasyAdminBundle Attribute Extend

README 文档

README

English | 中文

Latest Version Quality Score Total Downloads PHP Version License Code Coverage

A PHP attribute extension for EasyAdmin Bundle that provides a comprehensive set of attributes to configure admin interfaces using PHP 8 attributes. This package simplifies EasyAdmin configuration by leveraging PHP 8's attribute system to create clean, type-safe admin interfaces.

Table of Contents

Features

  • PHP 8 Attributes: Configure EasyAdmin entities using modern PHP 8 attributes
  • Rich Field Types: Support for Text, RichText, Select, ImagePicker, LinkageField and more
  • CRUD Operations: Complete set of attributes for List, Create, Edit, Delete, Copy, Import/Export operations
  • Advanced Filtering: Comprehensive filtering and search capabilities with keyword support
  • Form Validation: Built-in form layout configuration and validation attributes
  • Data Formatting: Automatic column formatting for FileSize, Boolean, Images, and other common types
  • Soft Delete: Support for soft delete operations with configurable behaviors
  • Flexible Display: Customizable display conditions, sorting options, and pagination
  • Permission System: Role-based access control with AsPermission attribute
  • Event Handling: Rich event system for customizing CRUD operations
  • Sub-CRUD Pages: Drawer-style popup sub-pages for complex data management
  • Custom Actions: Configurable header and row-level action buttons
  • Tree View: Hierarchical data display with parent-child relationships
  • Remote Data Loading: Support for large datasets with remote loading capabilities

Requirements

  • PHP 8.1 or higher
  • EasyAdmin Bundle 4.x
  • chrisullyott/php-filesize: ^4.2

Installation

composer require tourze/easy-admin-attribute

Quick Start

Basic Entity Configuration

<?php

use Tourze\EasyAdmin\Attribute\Action\Listable;
use Tourze\EasyAdmin\Attribute\Field\FormField;
use Tourze\EasyAdmin\Attribute\Action\Deletable;
use Tourze\EasyAdmin\Attribute\Column\ListColumn;

#[Listable]
#[Deletable(softDelete: true)]
class Product
{
    #[ListColumn]
    #[FormField(required: true)]
    private string $name;

    #[ListColumn]
    #[FormField(required: true)]
    private float $price;

    #[FormField]
    private string $description;
}

Permission-based Access Control

<?php

use Tourze\EasyAdmin\Attribute\Permission\AsPermission;
use Tourze\EasyAdmin\Attribute\Action\Listable;

#[AsPermission(name: 'product', title: 'Product Management')]
#[Listable(showTotal: true)]
class Product
{
    // Entity properties
}

Advanced Configuration

<?php

use Tourze\EasyAdmin\Attribute\Action\Listable;
use Tourze\EasyAdmin\Attribute\Field\SelectField;
use Tourze\EasyAdmin\Attribute\Column\PictureColumn;
use Tourze\EasyAdmin\Attribute\Filter\Filterable;

#[Listable(
    showPagination: true,
    actionWidth: 120,
    scrollX: 'max-content',
    showTotal: true,
    sortColumn: ['created_at' => 'DESC']
)]
#[Filterable]
class Product
{
    #[SelectField(entity: Category::class, choice: 'name')]
    private Category $category;

    #[PictureColumn(width: 60, height: 60)]
    private string $thumbnail;
}

Available Attributes

Action Attributes

  • Listable: Configure list view with pagination, sorting, and display options
  • Creatable: Enable entity creation with form configuration
  • Editable: Configure edit operations with custom validations
  • Deletable: Enable delete operations with soft delete support
  • Copyable: Add copy functionality to duplicate entities
  • Importable: Enable data import with template generation and field mapping
  • Exportable: Configure data export with custom column selection
  • BatchDeletable: Enable batch delete operations
  • CurdAction: Configure sub-CRUD pages with drawer-style popup
  • HeaderAction: Add custom action buttons to page headers
  • ListAction: Add custom action buttons to list rows

Field Attributes

  • FormField: Configure form fields with validation, layout, and display options
  • SelectField: Create select fields with entity relations and custom choices
  • RichTextField: Rich text editor integration with customizable toolbar
  • ImagePickerField: Image upload and selection with preview functionality
  • LinkageField: Create dependent dropdown fields with dynamic options
  • ImportField: Configure field mappings for data import operations

Column Attributes

  • ListColumn: Configure list view columns with sorting and formatting
  • ExportColumn: Specify export settings and column transformations
  • ImportColumn: Define import field mappings and data validation
  • FileSizeColumn: Automatic file size formatting (bytes to human readable)
  • PictureColumn: Image display configuration with thumbnail support
  • BoolColumn: Boolean value formatting with custom labels
  • CopyColumn: Column copying configuration for duplicate operations
  • TreeView: Configure hierarchical data display with parent-child relationships

Filter Attributes

  • Filterable: Add filtering capabilities to entity lists
  • Keyword: Enable keyword search on specific fields

Permission Attributes

  • AsPermission: Configure role-based access control for entities

Event Attributes

  • OnRowFormat: Customize row formatting in list views
  • OnLinkage: Handle linkage field dependencies
  • BeforeCreate/AfterCreate: Hooks for entity creation
  • BeforeEdit/AfterEdit: Hooks for entity editing
  • AfterSwitch: Handle field switching events
  • OnFilterQuery: Customize filter query building

Configuration Examples

List Configuration

#[Listable(
    showPagination: true,
    actionWidth: 120,
    scrollX: 'max-content',
    showTotal: true,
    totalTitleColumn: 'name',
    sortColumn: ['created_at' => 'DESC']
)]

Form Field Configuration

#[FormField(
    required: true,
    span: 12,
    label: 'Custom Label',
    placeholder: 'Enter value here',
    help: 'This is a help text'
)]

Column Configuration

#[ListColumn(
    sortable: true,
    width: 150,
    label: 'Custom Column Label'
)]

Advanced Features

Tree View Support

#[TreeView(
    parentField: 'parent',
    titleField: 'name',
    expandAll: false
)]

Custom Events

#[OnRowFormat(callback: 'formatProductRow')]
#[BeforeCreate(callback: 'validateProduct')]
#[AfterEdit(callback: 'updateProductCache')]

Import/Export Configuration

#[Importable(
    templateColumns: ['name', 'price', 'category'],
    requiredColumns: ['name', 'price']
)]
#[Exportable(
    filename: 'products-export',
    columns: ['name', 'price', 'category.name']
)]

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.

tourze/easy-admin-attribute 适用场景与选型建议

tourze/easy-admin-attribute 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tourze/easy-admin-attribute 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tourze/easy-admin-attribute 我们能提供哪些服务?
定制开发 / 二次开发

基于 tourze/easy-admin-attribute 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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