springworks/entity-diagrams
Composer 安装命令:
composer require springworks/entity-diagrams
包简介
Generate entity diagrams that show how the different parts of your Craft site relate to each other
README 文档
README
Generate entity diagrams that show how the different parts of your Craft site relate to each other
Requirements
This plugin requires Craft CMS 4.0.0 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project -
Then tell Composer to load the plugin:
composer require springworks/entity-diagrams -
In the Control Panel, go to Settings → Plugins and click the “Install” button for Entity Diagrams.
Entity Diagrams Overview
Have you ever wanted to get a visual overview of how the different elements of your Craft site fit together? Entity Diagrams enables you to do just that, producing an in-browser SVG that you can zoom and scale around, or download as an SVG file to re-use as you wish.
Supporting all the native top-level Craft elements (Entries, Categories, Tags, Users, Globals and Assets), you can choose to include all or none of an element type, or create custom document groupings that describe sub-sections of your site. Commerce Products are also supported if the Craft Commerce plugin is installed.
The plugin will scan the requested element types, and generate entity diagrams showing the element type, a list of all the fields (broken down by entry type and field layout tab) and will include connections between related element types directly from the relevant relations field.
There are options to include all fields or none and whether to expand Matrix blocks to include their sub-fields.
Using the entity-diagrams.php config file, you can add custom author links (useful if authors for a section always come from a particular user group).
You can also create custom nodes and links. These can be useful if you have custom database tables that interact with other elements of your site.
It’s a powerful tool to get a visual overview of how a complex site is structured adn can be really useful for onboarding new developers or when taking over a site developed by someone else.
Configuring Entity Diagrams
Entity Diagrams is configured by creating a config file named entity-diagrans.php in your Craft config folder (i.e. alongside the general.php and db.php config files).
The config file should look something like this:
<?php /** * entity-diagrams.php * * Optional manual config to create custom groupings of sections/category groups/globals/user groups/tag groups/asset volumes/products * to create entity diagrams of related parts of the system */ use craft\helpers\App; return [ 'docGroups' => [ // Create predefined groups of elements to show in a diagram, 'name' => config array ], 'options' => [ // default options, overridden by docGroups and UI 'includeFields' => 1, 'includeOnlyRelationFields' => 0, 'expandMatrixBlocks' => 1, 'includeAuthor' => 0, 'includeCustomNodes' => 0, 'includeCustomLinks' => 0, ], 'dotOptions' => [ 'rankDir' => 'LR', 'splines' => 'splines', 'title' => 'Site Diagram', ], ];
The most powerful feature of this is the ability to create pre-defined Document Groups (docGroups) of elements that represent a self-contained sub-section of a site. You can also use this feature to add custom nodes and links to a diagram.
Document Group definitions look like this:
<?php /** * entity-diagrams.php * * Optional manual config to create custom groupings of sections/category groups/globals/user groups/tag groups/asset volumes/products * to create entity diagrams of related parts of the system */ use craft\helpers\App; return [ 'docGroups' => [ // Create predefined groups of elements to show in a diagram, 'name' => config array 'Group Name' => [ 'sections' => [ // list all section handles to include 'news', 'pages', 'blog', ], 'categories' => [ // list all categoryGroup handles to include 'newsCategories', 'blogCategories', ], 'userGroups' => [ // list all userGroup handles to include 'contributors', 'editors', ], 'globals' => [ // list all global handles to include 'siteSettings', ], 'tags' => [ // list all tag group handles to include ], 'volumes' => [ // list all asset volume handles to include 'newsImages', 'blogImages', ], 'products' => [ // list all Commerce product type handles to include ], 'authorMap' => [ // map userGroups to sections if entry authorship in a section is limited to by userGroup 'news' => ['editors'], 'blog' => ['editors','contributors'], ], 'customNodes' => [ // add any custom nodes not handled automatically by Craft, e.g. custom database tables. ], 'customLinks' => [ // add any custom links not handled automatically by Craft, e.g. linking to a matrix block id in a field. Format: "section.handle|categoryGroup.handle|userGroup.handle[:field.handle] -> section.handle|categoryGroup.handle|userGroup.handle" ], 'options' => [ 'includeFields' => 1, 'includeOnlyRelationFields' => 0, 'expandMatrixBlocks' => 1, 'includeAuthor' => 1, 'includeCustomNodes' => 0, 'includeCustomLinks' => 1, ], ], ], 'options' => [ // default options, overridden by docGroups and UI 'includeFields' => 1, 'includeOnlyRelationFields' => 0, 'expandMatrixBlocks' => 1, 'includeAuthor' => 0, 'includeCustomNodes' => 0, 'includeCustomLinks' => 0, ], 'dotOptions' => [ 'rankDir' => 'LR', 'splines' => 'splines', 'title' => 'Site Diagram', ], ];
You can add as many Document Groups as you like.
Including all or no elements of a particular type
If you want to include all elements of a particular type, then set the array value to '*', like this:
... 'sections' => '*', // include all section handles ...
Similarly, to exclude all elements of a particular type, set the array value to an empty array, like this:
... 'tags' => [], // don't include any tag groups ...
Custom nodes and links
You can include custom nodes in a Document Group, e.g. custom database tables, etc., in an array like this:
... 'customNodes' => [ // add any custom nodes not handled automatically by Craft, e.g. custom database tables. [ 'name' => 'User Progress - Tasks', 'handle' => 'userProgressTasks', 'type' => 'DATABASE TABLE', 'fields' => [ 'task', 'user', 'status', ], ], ], ...
Similarly, custom links can be defined like this:
... 'customLinks' => [ // add any custom links not handled automatically by Craft, e.g. linking to a matrix block id in a field. Format: "section.handle|categoryGroup.handle|userGroup.handle[:field.handle] -> section.handle|categoryGroup.handle|userGroup.handle" 'userProgressTasks:task->taskEntries', ], ...
Using Entity Diagrams
Go to the Entity Diagrams control panel page, select what elements you want to include in your diagram, or choose a custom Document Group (defined in the entity-diagrams.php config file), then click Generate diagram. The diagram will be injected into the iframe below, where you can use the mouse and scroll wheel to zoom in and pan around the diagram.
The plugin generates a DOT file for the diagram, which is rendered by d3-graphviz as an SVG. You can download this SVG to use it in printed documentation or convert to a PDF.
There are various options to change how the diagram is rendered, though some of these aren't really well-suited for more complex diagrams. They are included more for completeness that anything else.
Support
The plugin is released under the MIT license, meaning you can do what ever you want with it as long as you don't blame us (and honor the original license). It's free, which means there is absolutely no support included, but you might get it anyway. Just post an issue here on GitHub if you have one, and we'll see what we can do.
Brought to you by Steve Rowling
springworks/entity-diagrams 适用场景与选型建议
springworks/entity-diagrams 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.16k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「Craft」 「craftcms」 「craft-plugin」 「entity diagrams」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 springworks/entity-diagrams 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 springworks/entity-diagrams 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 springworks/entity-diagrams 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Integrate with Snipcart.
Restrict user registration by domain in Craft CMS, allows you to limit who can register for your site based on their email address.
统计信息
- 总下载量: 1.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-30