PHPackages                             tuscanicz/doctrine-data-applier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. tuscanicz/doctrine-data-applier

ActiveLibrary[Database &amp; ORM](/categories/database)

tuscanicz/doctrine-data-applier
===============================

Symfony bundle for Doctrine Migrations of data using doctrine entities.

v0.9.1(9y ago)09MITPHP

Since May 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/tuscanicz/doctrine-data-applier)[ Packagist](https://packagist.org/packages/tuscanicz/doctrine-data-applier)[ Docs](https://github.com/tuscanicz/doctrine-data-applier)[ RSS](/packages/tuscanicz-doctrine-data-applier/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (12)Versions (4)Used By (0)

Doctrine data applier
=====================

[](#doctrine-data-applier)

Symfony bundle for Doctrine Migrations of data using doctrine entities. Use this tool to describe your database data by doctrine entities. It requires to modify your entities a bit but for that price, you'll get a mighty tool that will auto-merge entities in your application with those in your database.

This is very useful when you need to keep your data up-to-date in many environments and are necessary for your application to run.

Typical use-case is a user table with your administrator, content manager and other "obligatory" users or enumerations that are used across your app.

DataApplier will **never affect any data that was not created by DataApplier**so your user data can live next to data applier data together in one table.

How to use
----------

[](#how-to-use)

Add composer dependency: `composer require tuscanicz/doctrine-data-applier:dev-develop`

### Modify your Entity to be useful with Data Applier

[](#modify-your-entity-to-be-useful-with-data-applier)

You need to add some columns to doctrine entity to make them managable by data applier.

In order to do so you'll have to implement `DataApplier\Entity\DataApplicableEntityInterface`that will force you to use `DataApplier\Entity\DataApplicableEntityTrait`and present `id` column with setter and getter.

This id must be your primary key in database, see a typical annotation:

```
/**
 * @var int
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue()
 */
private $id;

public function getId()
{
    return $this->id;
}

public function setId(int $id)
{
    $this->id = $id;
}
```

I expect that most of the doctrine entities have such column already defined. If you define your id with different name or consists of complex keys, you'll have to fork this repository and fix this limitation :)

Next, you'll have to decide what are the DataApplier identifier columns.

This tool will decide whether to delete the row, update the data or insert new by matching your database contents with entities in your application.

Annotate them with `DataApplier\Annotation\DataApplierIdentifier`:

```
/**
 * @var string
 * @ORM\Column(type="string")
 * @DataApplierIdentifier()
 */
private $key;
```

Then create a factory method /or factory class that will set all the necessary attributes to your entity. Don't include the primary key in database (`id`), these will differ on your environments.

Example:

```
public static function createNew($value, $key)
{
    $self = new self;
    $self->setKey($key);
    $self->setValue($value);

    return $self;
}
```

### Update the database

[](#update-the-database)

Use `doctrine:migrations` to change the entities. Generating a diff will add a few columns that will help DataApplier to identify a source of data.

### Create a DataApplier for your entity

[](#create-a-dataapplier-for-your-entity)

Data applier consists of multiple DataAppliers that will implement `DataApplier\Data\DataApplierInterface`.

The only method `applyData()` will return an array of entities that you need to keep in your database:

```
class TestDataApplier1 implements DataApplierInterface
{
    public function applyData()
    {
        return [
            TestEntity::createNew('value1', 'key1'),
            TestEntity::createNew('value2', 'key2'),
            TestEntity::createNew('value3', 'key3'),
        ];
    }
}
```

You must register `TestDataApplier1` as Symfony service and add `doctrine.data_applier` tag:

```

```

### Register DataApplier bundle

[](#register-dataapplier-bundle)

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...,
            new \DataApplier\DataApplierBundle()
        ];
    }
}
```

### Run DataApplier

[](#run-dataapplier)

If you managed to go thru all the previous steps - congratulations. :)

You can now run your data applier via Symfony console: `php bin/console data:apply`

This will update your data in your database.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3317d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5862953?v=4)[Petr Bechyně](/maintainers/tuscanicz)[@tuscanicz](https://github.com/tuscanicz)

---

Top Contributors

[![tuscanicz](https://avatars.githubusercontent.com/u/5862953?v=4)](https://github.com/tuscanicz "tuscanicz (3 commits)")

---

Tags

datadatabasedoctrineentitymigrationssymfonysymfony-bundledatadoctrinemigrations

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tuscanicz-doctrine-data-applier/health.svg)

```
[![Health](https://phpackages.com/badges/tuscanicz-doctrine-data-applier/health.svg)](https://phpackages.com/packages/tuscanicz-doctrine-data-applier)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k58](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
