dsnetpl/doctrine-column-comment-bundle

修改doctrine元数据,使doctrine知道数据库中的列有额外的信息 - 一个注释。

v1.0.1 2023-12-17 21:22 UTC

This package is auto-updated.

Last update: 2024-09-17 23:12:22 UTC


README

phpWorkflow

适用于Symfony >= 4.4.0的Bundle

修改doctrine元数据,使doctrine知道数据库中的列有额外的信息。

安装

$ composer require dsnetpl/doctrine-column-comment-bundle

如果项目中没有使用 Symfony Flex,则需要注册一个Bundle

# config/bundles.php
return [
    // ...
    Dsnetpl\DoctrineColumnCommentBundle::class => ['all' => true],
];

使用

为了在数据库中的数据表字段上添加自动注释。需要修改Entity文件

//...

    /**
     * Comment must be written in docblock
     *
     * @ORM\Column()
     */
    private string $field;

//..

下一步是创建数据库的diff

$ bin/console doctrine:schema:update --dump-sql

如果一切配置正确,应该生成以下查询

COMMENT ON COLUMN table.field IS 'Comment must be written in docblock'