maci / admin-bundle
Maci的Symfony Admin Generator Bundle
v0.6.1
2017-07-10 04:01 UTC
Requires
- knplabs/knp-menu-bundle: ~2.0
- symfony/symfony: ~2.7|~3.2
This package is auto-updated.
Last update: 2024-09-30 01:35:53 UTC
README
MaciAdminBundle 允许您轻松为 Symfony 4 应用程序创建管理后端。
警告:这是一个开发中的alpha版本。
缺少
- 测试
- 过滤器(但提供了搜索功能)
- 更多示例请参阅文档
- 一些其他小功能
特性
- 不同角色的分区
- 实体操作:列表、新建、回收站、显示、编辑、关联、删除、上传和重新排序
- 实体关联:列表、设置/添加、删除(项目/关联)、上传和重新排序
要求
- 支持SYMFONY 4.4
- Doctrine ORM实体(不支持Doctrine ODM和Propel)。
❮ 注意 ❯ 您正在阅读该包的开发版本文档。
安装
步骤 1:下载Bundle
$ composer require maci/admin-bundle:dev-master
此命令需要您全局安装Composer,具体请参阅Composer文档。
步骤 2:启用Bundle
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Maci\AdminBundle\MaciAdminBundle(), ); } // ... }
步骤 3:加载Bundle的路由
# app/config/routing.yml maci_admin: resource: "@MaciAdminBundle/Resources/config/routing.yml" prefix: /mcm # ...
步骤 4:设置“列表”页面的缩略图大小(对于具有预览的实体)
# Liip Configuration liip_imagine: filter_sets: maci_admin_list_preview: quality: 80 filters: thumbnail: { size: [90, 90], mode: inbound }
步骤 5:准备Bundle的Web资源
# Symfony 2.7
php app/console assets:install --symlink
# Symfony 3
php bin/console assets:install --symlink
就这样!现在一切准备就绪,可以创建您的第一个管理后端。
您的第一个后端
创建第一个后端只需不到30秒。假设您的Symfony应用程序定义了三个名为Product、Category和Page的Doctrine ORM实体。
打开app/config/config.yml
文件并添加以下配置
# app/config/config.yml maci_admin: sections: all: dashboard: 'AppBundle:Default:my_dashboard.html.twig' # optional entities: product: 'AppEntityBundle:Product' category: 'AppEntityBundle:Category' page: class: 'AppBundle:Page' list: ['title', 'path', 'template', 'locale'] config: # optional roles: [ROLE_ADMIN] # default
恭喜!您已经创建了一个功能齐全的后端! 浏览Symfony应用程序中的/mcm
URL,即可访问管理后端
完整配置
# app/config/config.yml maci_admin: sections: medias: dashboard: 'AppBundle:Default:media_dashboard.html.twig' # optional entities: # in this example an entity 'media' is associated to an 'album' trough a 'media item' # then: Album >1toM< MediaItem >Mto1< Media # 'media', 'album' and 'media item' are here in a section named 'medias' album: 'AppBundle:Album' media: # an 'entity map' bridges: [] # default class: 'AppBundle:Media' form: 'AppBundle\Form\Type\FormType' label: 'Image' #example, default is the name of the section capitalized list: ['_preview', 'name', 'type'] # columns in list views, default is [] (= all fields) relations: items: # label and list are inherited from the 'entity map' label: 'Image Items' #example list: [] config: # -relation- config, inherited from the -entity- config: enabled: true roles: [] sortable: false # if true, in this example allow to sort the 'media items' of an 'album' sort_field: 'position' actions: [] trash: true trash_field: 'removed' uploadable: true upload_field: 'file' config: # -entity- config, inherited from the -section- config: enabled: true roles: [] sortable: false sort_field: 'position' actions: # default is [] list: 'AppBundle:Default:list.html.twig' show: controller: 'appbundle.controller' template: 'AppBundle:Default:list.html.twig' # actions are: list, show, new, trash, show, edit, relation, remove, uploader, # relations_list, relations_add, ('list' and 'add' for the sides of relations with multiple elements, like -MANY-toOne) # relations_show, relations_set ('list' and 'set' for the sides of relations with a single element, like -ONE-toMany), # relations_uploader (in this example this action can be used to directly upload some media in an album) trash: true trash_field: 'removed' uploadable: true upload_field: 'file' media_item: class: 'AppBundle:MediaItem' bridges: 'media' # or ['media', ...] in this example allow to add directly media to an album config: # -section- config, inherited from the -default- config: enabled: true roles: [ROLE_ADMIN] sortable: false sort_field: 'position' actions: [] trash: true trash_field: 'removed' uploadable: true upload_field: 'file' # other optional sections blog: entities: post: 'AppBundle:Post' tag: 'AppBundle:Tag' config: # -default- config: controller: 'maci.admin.controller' # the service controller that contain the Action functions, see the ViewController for more informations enabled: true roles: [ROLE_ADMIN] sortable: false # if true, allow to sort items in the 'list' action, usually this is needed only in relations sort_field: 'position' # sort is made by field 'position' actions: [] trash: true # allow to trash items of an entity trash_field: 'removed' # trash folder is filtered by field 'removed' uploadable: true upload_field: 'file'
许可
本软件根据MIT许可证发布