dualmedia/dynamic-orm-value-bundle
Composer 安装命令:
composer require dualmedia/dynamic-orm-value-bundle
包简介
Bundle for disabling fields in DoctrineORM
README 文档
README
Dynamic ORM Value Bundle
A Symfony + Doctrine bundle to allow dynamic values on entity persisting.
This bundle will allow you to configure dynamic values to be created for entities when they are persisted in the application.
Install
Simply composer require dualmedia/dynamic-orm-value-bundle
Then add the bundle to your config/bundles.php file like so
return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], // other bundles ... DualMedia\DynamicORMValueBundle\DynamicORMValueBundle::class => ['all' => true], ];
Setup
Mark the properties you'd like to generate dynamically upon persisting with #[DynamicValue] with appropriate options.
To let the bundle discover your entities you must create a symfony configuration file (by default it's yaml) and add any required fields.
A sample configuration is provided below
# dm_dynamic_orm.yaml dm_dynamic_orm: entity_paths: # list of directories that contain your entities - '%kernel.project_dir%/src/SimpleApi/Entity' - '%kernel.project_dir%/src/Common/Entity' - '%kernel.project_dir%/src/ExternalApi/Entity'
Entity example
Say you have an order entity, but you use a numerical id for easy tracking. But you also want to show a "simple" order id for your users. This value obviously needs to be generated, which is fine if you have 1 entity like this. But what if it's your order, your internal transaction stuff, a username, and more?
This bundle solves this repeating code issue and allows for a nice way to configure it.
#[ORM\Entity] class MyOrder { #[ORM\Id] #[ORM\Column(name: 'id', type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] private int|null $id; // your other fields #[ORM\Column] #[DynamicValue(options: ['length' => 10])] // 8 is default private string|null $publicId = null; }
Your field publicId will now be automatically generated when the entity is being persisted. You don't need to worry about uniqueness, as it's checked during generation.
dualmedia/dynamic-orm-value-bundle 适用场景与选型建议
dualmedia/dynamic-orm-value-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 331 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dualmedia/dynamic-orm-value-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dualmedia/dynamic-orm-value-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 331
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-24