承接 dualmedia/disable-orm-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dualmedia/disable-orm-bundle

最新稳定版本:1.0.4

Composer 安装命令:

composer require dualmedia/disable-orm-bundle

包简介

Bundle for disabling fields in DoctrineORM

README 文档

README

Packagist Downloads

DisableORM Bundle

A Symfony + Doctrine bundle to allow disabling fields from being seen by DoctrineORM.

Why

This bundle will allow you to seamlessly update your application, assuming you have multiple versions running at the same time, with different database expectations.

While adding new entities is not an issue, as they're simply not present in the old application versions, this is not the case for entities being modified. You must either shut down all instances before running migrations which could cause differences in database schema expectations or... use this bundle.

With this, you're able to safely "remove" a field, so that the old version of the application can still use it before update, and the new one can ignore it.

As this modifies the ORM metadata the field is transparently removed from ORM and is not usable outside of raw SQL queries.

Install

Simply composer require dualmedia/disable-orm-bundle

Then add the bundle to your config/bundles.php file like so

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // other bundles ...
    DualMedia\DisableORMBundle\DisableORMBundle::class => ['all' => true],
];

Setup

You must manually set the doctrine class metadata factory name value under your entity manager to use this bundle.

doctrine:
  orm:
    entity_managers:
      <manager_name>:
        class_metadata_factory_name: DualMedia\DisableORMBundle\Factory

Config

dm_disable_orm:
  # you can specify commands which should not be affected by DisableORM logic
  # defaults are below, you don't need to modify them unless you want to
  disable_on_commands:
    - 'doctrine:schema:validate'
    - 'doctrine:migrations:diff'

Usage

The #[DisableORM] attribute prevents doctrine from loading and creating the column from the database.

You should set a default value for the column before this, as otherwise you might get issues inserting new entities!

Use your entities as usual, when you decide you want to remove a field from it simply add #[DisableORM] on it, then update your application once.

From then, you can safely remove the field with a migration while not causing any downtime.

Example

#[ORM\Entity]
class FooEntity {
    #[ORM\Column]
    public int|null $normalField = null;

    #[DisableORM]
    #[ORM\Column(options: ['default' => false])]
    public int|null $someField = null;
    
    // ... getters and setters, etc.
}

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-19