PHPackages                             pavelvais/upsert-doctrine - 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. pavelvais/upsert-doctrine

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

pavelvais/upsert-doctrine
=========================

Doctrine helper for update and insert functionality

v0.2.1(2y ago)2151MITPHPPHP &gt;=8.0

Since Oct 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/PavelVais/upsert-doctrine)[ Packagist](https://packagist.org/packages/pavelvais/upsert-doctrine)[ RSS](/packages/pavelvais-upsert-doctrine/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Upsert-Doctrine
===============

[](#upsert-doctrine)

[![PHP Unit Tests](https://github.com/PavelVais/upsert-doctrine/actions/workflows/php.yml/badge.svg?branch=main)](https://github.com/PavelVais/upsert-doctrine/actions/workflows/php.yml)

Upsert-Doctrine is a PHP library aimed at providing an elegant solution for upsert operations in Doctrine. This library simplifies the process of either inserting a new record or updating an existing one in a single operation, all within the Doctrine ORM ecosystem.

Installation
------------

[](#installation)

Install Upsert-Doctrine using [Composer](https://getcomposer.org/):

```
composer require pavelvais/upsert-doctrine
```

Usage
-----

[](#usage)

Below is a basic example demonstrating how to use Upsert-Doctrine:

```
use PavelVais\UpsertDoctrine\UpsertManager;

$entityManager = // ... get your Doctrine entity manager here
$upsertManager = new UpsertManager($entityManager);

// Example for Single Upsert
$data = [
    'book_id' => 1,
    'author_id' => 2,
    'ownership_type' => 2,
];
$repositoryClass = DoctrineOrmEntity::class; // Replace with your actual repository class

try {
    $result = $upsertManager->execute($data, $repositoryClass);
    // $result will contain the number of affected rows
} catch (\Exception $e) {
    // Handle exceptions
}

// Example for Batch Upsert
$batchData = [
    [
        'book_id' => 1,
        'author_id' => 2,
        'ownership_type' => 2,
    ],
    [
        'book_id' => 2,
        'author_id' => 3,
        'ownership_type' => 1,
    ],
];

try {
    $result = $upsertManager->executeBatch($batchData, $repositoryClass);
    // $result will contain the number of affected rows
} catch (\Exception $e) {
    // Handle exceptions
}
```

Local Testing with Docker
-------------------------

[](#local-testing-with-docker)

This project includes a Docker setup to run local testing and development. Here are the steps to get started:

1. **Build and manage the Containers**: Build and start the containers in the background.

    ```
    make build
    ```

    To stop and remove the containers, use the following command:

    ```
    make stop
    ```
2. Installing Dependencies: Install the project dependencies using Composer with the following command:

    ```
    make composer-install
    ```
3. Running Tests: Run the PHPUnit tests to ensure everything is working as expected.

    ```
    make test
    ```

Roadmap
-------

[](#roadmap)

- Basic Upsert Functionality
- Batch Upsert method
- Query Manager
- Postgres Support
- Live database testing

Contributing
============

[](#contributing)

Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change. Ensure to update tests as necessary.

License
=======

[](#license)

This project is licensed under the MIT License - *see the [LICENSE](LICENSE) file for details.*

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

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 ~4 days

Total

3

Last Release

933d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f66169696f93e128098132892d1a4ccd56f414c9a23eea201b32a03b2a055f67?d=identicon)[PavelVais](/maintainers/PavelVais)

---

Top Contributors

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

---

Tags

dbaldoctrinedoctrine-ormmariadbmysqlsymfony

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pavelvais-upsert-doctrine/health.svg)

```
[![Health](https://phpackages.com/badges/pavelvais-upsert-doctrine/health.svg)](https://phpackages.com/packages/pavelvais-upsert-doctrine)
```

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1183.0k1](/packages/bartlett-php-compatinfo-db)[heymoon/doctrine-psql-enum

Store PHP native enums as PostgeSQL custom enum types

254.9k](/packages/heymoon-doctrine-psql-enum)

PHPackages © 2026

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