musicjerm / jermbundle
JermBundle Library for Symfony 4 projects
This package is auto-updated.
Last update: 2024-09-18 23:16:32 UTC
README
JermBundle 是一个定制的以数据为中心的 CMS,专为与 Symfony PHP 项目一起使用而构建。包括 CRUD 方法、数据导入/导出工具、用户角色管理、可定制的前端元素等!
安装方法
composer require musicjerm/jermbundle
请查看以下要求、配置和其他信息。
功能
- 一个可配置的 CRUD 控制器,与 Doctrine 实体映射相关联。标准 CRUD 功能被简化为 "操作"。
- 易于使用的基于配置的导入控制器,可以处理包含数十万行的大型 CSV 文件。
- 列和筛选预设管理,允许用户自定义并保存他们的数据筛选器和列选择。
- 前端模板,包括导航、数据表、筛选器和分页。旨在提供一种干净的流程和灵感来自管理员的外观,这些模板可以扩展或替换。
- 通知和订阅事件和方法。
- 基础 Doctrine 实体。
- 易于导出数据,每个实体都有可定制的列。
- 用户角色控制数据可见性和操作。
要求
- PHP 7.2 或更高版本
- Symfony 4 或 Symfony 5
- Doctrine
- PHPOffice/PhpSpreadsheet 以导出 Excel 格式的数据
前端(建议利用所有功能)
- Twig
- Bootstrap 3
- AdminLTE 3
- Fontawesome 图标集
- JQuery 3.7.0
- JQuery Datatables
- Jquery Select2
- Bootstrap Datepicker
- Bootstrap Timepicker
- JQuery slimscroll
- JQuery inputmask
- ClipboardJs
设置您的应用程序
在安装软件包之后,请确保将以下内容添加到您的 /project/config/bundles.php
文件中:Musicjerm\Bundle\JermBundle\JermBundle::class => ['all' => true],
。路由 jerm_bundle_data_index
将需要创建实体配置文件,并将提供软件包的大部分基础布局,包括导航、数据表、筛选器和其他可定制的元素。
您还希望查看位于 路由 配置中的可用方法和模块。
包含的 Twig 模板可以在 这里 找到。
导航配置
如果您使用的是推荐的前端库,则可以利用可配置的路由和与用户角色关联的导航。此文件必须包含在 src/JBConfig/nav.yaml
中。您最多可以有 3 层子导航组。以下是一个示例
# /project_dir/src/JBConfig/nav.yaml Home: route: 'homepage' role: 'IS_AUTHENTICATED_ANONYMOUSLY' icon: 'fa-home' Invites: route: 'jerm_bundle_data_index' parameters: {entity: 'invite'} role: 'ROLE_USER' icon: 'fa-envelope' Booking: Appointments: route: 'jerm_bundle_data_index' parameters: {entity: 'appointment'} role: 'ROLE_BOOKING' icon: 'fa-book' Calendar: route: 'booking_calendar_index' role: 'ROLE_BOOKING' icon: 'fa-calendar'
实体配置
由于 JermBundle 是围绕数据管理设计的,因此需要创建一些可配置的 YAML 文件,这些文件与特定的 Doctrine 实体相关联。这些文件将存储在您的项目目录 src/JBConfig/Entity/
中。以下是一个示例
# /project_dir/src/JBConfig/Entity/location.yaml entity: 'App\Entity\Location' role: 'ROLE_SUPERVISOR' page_name: 'Locations' template: 'dataIndex/location.html.twig' # columns determine which Doctrine properties are displayed and # each line must include the following: # title - What the columns should be called, can be anything # data - this is a getter minus the 'get' from the associated doctrine entity # sort - passed to the data table for sorting columns: - { title: 'ID', data: 'id', sort: 'l.id' } - { title: 'Parent Location', data: 'parentLocation', sort: 'l.parentLocation' } - { title: 'Default Job', data: 'defaultJob', sort: 'l.defaultJob' } - { title: 'Name', data: 'name', sort: 'l.name' } - { title: 'Address', data: 'address', sort: 'l.address' } - { title: 'City', data: 'city', sort: 'l.city' } - { title: 'State', data: 'state', sort: 'l.state' } - { title: 'Zip', data: 'zip', sort: 'l.zip' } - { title: 'Market', data: 'market', sort: 'l.market' } - { title: 'Contact ID', data: 'userContact.id', sort: 'l.userContact' } - { title: 'Contact Name', data: 'userContact.fullName', sort: 'c.userContact' } - { title: 'Contact E-mail', data: 'userContact.email', sort: 'c.userContact' } - { title: 'Contact Phone', data: 'userContact.phone', sort: 'c.phone' } - { title: 'Alternate Contact', data: 'altContactName', sort: 'l.altContactName' } - { title: 'Alternate Contact E-mail', data: 'altContactEmail', sort: 'l.altContactEmail' } - { title: 'Alternate Contact Phone', data: 'altContactPhone', sort: 'l.altContactPhone' } - { title: 'Buyer E-mail', data: 'buyer', sort: 'l.buyer' } - { title: 'Active', data: 'isActiveString', sort: 'l.isActive' } - { title: 'Default Skin', data: 'defaultSkin', sort: 'l.defaultSkin' } - { title: 'Created By', data: 'userCreated', sort: 'l.userCreated' } - { title: 'Updated By', data: 'userUpdated', sort: 'l.userUpdated' } - { title: 'Created On', data: 'dateCreated', sort: 'l.dateCreated' } - { title: 'Updated On', data: 'dateUpdated', sort: 'l.dateUpdated' } # key is required for item and group actions and the associated value for an object is passed in the route parameters key: 'id' # default indexes that are initially available to a user view: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18] # default indexes for columns that might be exported by a user dump: [1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18] # default indexes for tooltips - must be one digit for every available column # -1 indicates no tooltip for that position tooltip: [-1, 4, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # default sort key and direction sortId: 23 sortDir: 'desc' # filters can be assigned here, these can be text fields, selectors (with entity association), # radios or checkboxes JermBundle does its best to support nearly any possible filter necessary # and also supports a custom implementation. For these to work a StandardQuery method must be # included in the EntityRepository class. filters: - { name: 'Search', type: 'Text' } - name: 'Active' type: 'Choice' array: choices: {Yes: true, No: false} placeholder: 'Any' # actions are a form of customizable data manipulation method separated into 3 categories # head actions will be placed in the admin panel at the top and are typically used for new # object creation or mass edits. # item actions are actions on a single entity such as a CRUD update. # group actions are actions on a selection of items that will be updated together. # These are keyed by the symfony route name. actions: head: jerm_bundle_crud_create: role: 'ROLE_ADMIN' text: 'New' icon: 'fa-plus' btn: 'btn-primary' params: { entity: 'location' } front_load: - 'app/js/select2query.js' item: jerm_bundle_crud_update: role: 'ROLE_ADMIN' icon: 'fa-pencil' text: 'Edit' params: { entity: 'location' } front_load: - 'app/js/select2query.js' group: jerm_bundle_crud_delete: role: 'ROLE_ADMIN' text: 'Delete Selected' params: { entity: 'location' } # importer configuration # supply the namespace of a data transformer within the application and JermBundle will create # a customized importer action. Headers must map to Doctrine entity properties. # unique, required and associated values are taken into consideration when data is handled. # batch size can be set or a default of 1000 will be used import: transformer: 'App\Transformer\LocationImportTransformer' headers: - 'name' - 'address' - 'city' - 'state' - 'zip' - 'market' keys: [0, 1] batch_size: 3000
关于操作的其他信息
JermBundle 操作与 CRUD 方法相关,也可以是用于以特定方式操纵数据的自定义方法。在基本级别上,这些操作只是指向模块、表单或函数的路由链接,它们将呈现为模态视图。导航链接分为 3 个类,这些类最初在 JBConfig/Entity YAML 文件中配置。请参阅上面的示例。
列和过滤器预设
预设配置包含在软件包中,一旦您的实体配置文件设置完毕即可直接使用!这允许用户定义自己的预设,指定哪些列将显示和导出。
其他使用案例
JermBundle 能够作为一个文件管理平台,甚至已经被用来同步本地存储与亚马逊的 S3 云存储。
待办事项
- 精炼依赖项版本要求并更新此说明。
- 更新基础 Doctrine 实体以使用 PHP 8 注释。
- 清理控制器及注释。
- 更新 Bootstrap 和 AdminLTE 到版本 4,或者可能实现一个使用 Vue 的现代前端。
- 向 CRUD 控制器添加额外功能,特别是实现使用数据转换器而不是依赖严格的实体映射。