fastbolt/entity-archiver-bundle
Composer 安装命令:
composer require fastbolt/entity-archiver-bundle
包简介
Archives Doctrine entities
README 文档
README
EntityArchiverBundle handles automatic archiving or removal of doctrine entities in the application.
Installation:
composer require fastbolt/entity-archiver-bundle
You will need to create an entity-archiver.yaml file in your config directory. See 'Configuration' below.
To use the command, you will need to add the following line to the bundles.php:
Fastbolt\EntityArchiverBundle\EntityArchiverBundle::class => ['all' => true]
Execute by using this command:
php bin/console entity-archiver:run
Options:
--dry-run Will only display the results table, showing all entities from entity-archiver.yaml, the total number of entries in the origin table and the number of entities selected for archiving
--update-schema Will update the archive tables based on the configuration in entity-archiver.yaml
Configuration
Example:
#entity-archiver.yaml entity_archiver: table_suffix: archive entities: - entity: App\Entity\Log strategy: archive filters: - { type: age, age: 1, unit: months, field: created_at } archivingDateFieldName: archived_at fields: [ 'id', 'item_type', 'item_id', 'item_description', 'item_action', 'fk_client_id', 'fk_user_id' ]
table_suffix Suffix of the tables created by the bundle to hold the archived entities
addArchivedAt Wether to add a field for the archiving date in the archive table
archivingDateFieldName Field name of the generated date field holding the date when the archiving was done, default 'archived_at'
strategy What to do with the entity when it is selected to be archived
- remove Deletes the enitity using the 'id'-column
- archive Removes it from the original table and pastes a non-unique copy to the archive table
filters:
- type: age
- age integer
- unit ("days"/"months"/"years")
- field Entity field that is used to determin the age of the entry (Datetime)
Adding new Filters and Strategies: New filters need to implement the EntityArchivingFilterInterface, while strategies will need to implement the ArchivingStrategyInterface. Add the corresponding tag in the services.yaml.
Fastbolt\EntityArchiverBundle\Filter\AgeArchivingFilter: tags: [ 'fastbolt.archiver.filter' ] Fastbolt\EntityArchiverBundle\Strategy\ArchiveStrategy: tags: [ 'fastbolt.archiver.strategy' ]
Make doctrine ignore archive Tables: Doctrine will generate migrations to delete the generated archive tables, as they are not connected to an entity. To prevent that, add an exception to your doctrine configuration (replace '_archive' if you changed the table suffix):
#doctrine.yaml doctrine: dbal: schema_filter: ~^(?!.*_archive$)~
fastbolt/entity-archiver-bundle 适用场景与选型建议
fastbolt/entity-archiver-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 473 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fastbolt/entity-archiver-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fastbolt/entity-archiver-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 473
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-11