Download the PHP package dualmedia/disable-orm-bundle without Composer
On this page you can find all versions of the php package dualmedia/disable-orm-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dualmedia/disable-orm-bundle
More information about dualmedia/disable-orm-bundle
Files in dualmedia/disable-orm-bundle
Package disable-orm-bundle
Short Description Bundle for disabling fields in DoctrineORM
License MIT
Informations about the package disable-orm-bundle
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
Setup
You must manually set the doctrine class metadata factory name value under your entity manager to use this bundle.
Config
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
PHPStan Rule
Simply add the following to your PHPStan config to enable a simple check for your entities (only applies if you're using PHP8 Attributes)
Git change detection
To prevent breaking your application on accident you may add the script in /scripts to your CI to automatically detect possibly incorrect removals of fields.
As when using this bundle it is expected, that a removed field WILL contain the DisableORM attribute, before being deleted, because of that, we can catch invalid field removals in the CI steps.
A Gitlab CI declaration is provided in the .gitlab-ci.job.yml file, simply include it and then extend it as required.
All versions of disable-orm-bundle with dependencies
doctrine/doctrine-bundle Version ^2 || ^3
doctrine/orm Version ^3
symfony/framework-bundle Version ^6.4 || ^7.4 || ^8.0