onurb / doctrine-yuml-bundle
Symfony Bundle,用于使用 Yuml 可视化您的实体映射
Requires
- php: >=7.1.3
- doctrine/annotations: 1.*
- doctrine/common: ~2.0
- doctrine/orm: ~2.0
- onurb/doctrine-metadata-grapher: ~1.0
- symfony/config: ~4.2
- symfony/console: ~3.0|~4.0
- symfony/dependency-injection: ~3.0|~4.0
- symfony/framework-bundle: ~3.0|~4.0
- symfony/http-foundation: ~3.0|~4.0
- symfony/http-kernel: ~3.0|~4.0
- symfony/profiler-pack: ~1.0
- symfony/routing: ~3.0|~4.0
Requires (Dev)
- php: >=7.0
- doctrine/doctrine-bundle: ^1.5
- phpunit/phpunit: ~6.5
- squizlabs/php_codesniffer: ~2
README
用于在 Symfony4 中可视化 doctrine 实体图形的 yuml 包
此包基于 Marco Pivetta 为 zend doctrine ORM 模块和 zend 开发者工具所做的作品
它使用 yuml.me API 来显示您项目的对象映射。
安装
Symfony 4
在您的控制台运行 composer require onurb/doctrine-yuml-bundle
命令
调整您的参数以在 config/packages/dev/yuml.yaml 中个性化渲染,或使用下面的注释
调整路由(如果您想添加前缀)在 config/routes/dev/yuml.yaml
Symfony 3
symfony 3 自 1.1.6 起不再支持,如果您尚未迁移到 SF4,请使用版本 1.1.5
- 将此包添加到您的项目中作为 composer 依赖项
// composer.json { // ... require: { // ... "onurb/doctrine-yuml-bundle": "1.1.5" } }
- 在您的应用程序内核中声明此包
// app/AppKernel.php public function registerBundles() { // ... if (in_array($this->getEnvironment(), array('dev', 'test'))) { // ... $bundles[] = new Onurb\Bundle\YumlBundle\OnurbYumlBundle(); } return $bundles; }
- 将此路由添加到您的全局路由_dev 配置(带有可选的前缀)
# app/config/routing_dev.yml # ... doctrine_yuml: resource: "@OnurbYumlBundle/Resources/config/routing.yml" prefix: /my_prefix/
配置对 yuml 路由的访问(如果您使用安全功能的话)
使用
点击开发工具栏中添加的 Doctrine 图标。
运行 yuml:mappings
控制台命令以将图像保存到本地。
个性化渲染
对映射渲染进行完全个性化,定义参数或使用 Metadatagrapher 注释
定义输出文件扩展名
使用参数文件
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.extension: svg # ...
允许的扩展名:jpg, png(默认),svg, pdf 或 json
定义 yuml 渲染样式
使用参数文件
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.style: scruffy # ...
允许的样式:plain(默认),boring 或 scruffy
定义图形方向
使用参数文件
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.direction: LR # ...
允许的方向:LR(从左到右),RL(从右到左),TB(从上到下 => 默认)。
定义图形比例
使用参数文件
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.scale: huge # ...
允许的比例:huge, big, normal(默认),small 或 tiny。
隐藏实体属性属性(唯一,类型,长度,...)
使用参数文件
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.show_fields_description: false # ...
此参数从 v1.1 版本默认设置为 true
注意:在 Symfony 3 中,不要忘记在 parameters.yml.dist 中定义参数键,以避免 symfony 更新
清除您的参数
使用注释切换特定类的属性
如果全局参数设置为 false,则仅显示所需类的详细信息
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\ShowAttributesProperties() */ Class MyClass { // ... }
如果设置为 true(默认),则可以隐藏特定类的属性
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\HideAttributesProperties() */ Class MyClass { // ... }
为实体渲染定义颜色
通过在 parameters.yml 中定义它来定义整个包或命名空间的颜色
# app/config/parameters.yml => Symfony 3 # config/packages/dev/yuml.yaml => Symfony 4 parameters: onurb_yuml.colors: App\Security: red App\Blog: blue # ...
您也可以这样定义类的颜色...但使用下面的注释会更简单
可用的 yuml 颜色完整列表 在这里
在图形中使用注释定义实体颜色
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\Color("blue") */ Class MyClass { }
显示特定实体方法
您可以使用注释在图形中显示特定方法
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; // ... Class MyEntity { // ... /** * @Grapher\IsDisplayedMethod() */ public function myDisplayedMethod() { // ... } }
隐藏列
隐藏实体的所有列
如果您想,您可以使用注释隐藏实体的属性:在类上使用注释
/** * @Grapher\Hidecolumns */ MyEntity { //[...] }
隐藏特定列
或者隐藏您想要隐藏的特定密钥列,使用实体列上的注释:(这可以用于隐藏您的凭据逻辑,或者避免显示重复字段,如图表中的 created_at 或 updated_at...)
MyEntity { /** * @ORM\Column(/* ... */) * @Grapher\HiddenColumn */ private $secret; }
在图中为注释实体添加注释
使用注释
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\Note("Some information about this class") */ Class MyClass { }
默认情况下,注释为黄色,但您可以自定义注释的颜色
/** * @Grapher\Note(value="Some information about this class", color="blue") */