PHPackages                             phpro/zf-apigility-doctrine-bulk - 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. phpro/zf-apigility-doctrine-bulk

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

phpro/zf-apigility-doctrine-bulk
================================

A module that provides an extendable and fast way of adding bulk actions to the doctrine apigility module.

v0.1.5(10y ago)41.5k2PHP

Since Jun 13Pushed 5y ago7 watchersCompare

[ Source](https://github.com/phpro/zf-apigility-doctrine-bulk)[ Packagist](https://packagist.org/packages/phpro/zf-apigility-doctrine-bulk)[ RSS](/packages/phpro-zf-apigility-doctrine-bulk/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (14)Versions (6)Used By (0)

> ## Repository abandoned 2020-11-27
>
> [](#repository-abandoned-2020-11-27)
>
> This repository has been archived since we are not using it anymore internally. Feel free to use it AS-IS, we won't be providing any support anymore.

Apigility Doctrine Bulk Module
==============================

[](#apigility-doctrine-bulk-module)

This module provides an extendable and fast way of adding bulk actions to the doctrine apigility module. It is based on the bulk API of [elasticsearch](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html).

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

[](#installation)

```
curl -s https://getcomposer.org/installer | php
php composer.phar install

```

Module Installation
-------------------

[](#module-installation)

### Add to composer.json

[](#add-to-composerjson)

```
"phpro/zf-apigility-doctrine-bulk": "dev-master"

```

### Add module to application.config.php

[](#add-module-to-applicationconfigphp)

```
return array(
    'modules' => array(
        'Phpro\Apigility\Doctrine\Bulk',
        // other libs...
    ),
    // Other config
);
```

### Add your custom bulk endpoints to the configuration

[](#add-your-custom-bulk-endpoints-to-the-configuration)

```
return [
    // A normal RPC route:
    'router' => [
        'routes' => [
            'api.rpc.bulk' => [
                'type' => 'Segment',
                'options' => [
                    'route' => '/api/bulk',
                    'defaults' => array(
                        'controller' => 'Api\V1\Rpc\Bulk\BulkController',
                        'action' => 'bulk',
                    ],
                ],
            ],
        ]
    ],

    /*
     * A new bulk controller:
     * - entity_class: the classname of the doctrine entity
     * - object_manager: the key of the desired object manager in the service manager
     * - hydrator: the key of the desired hydrator in the hydrator manager
     * - listeners: custom bulk action listeners that are being loaded from the service manager
     */
    'zf-apigility' => [
        'doctrine-bulk-handlers' => [
            'Api\V1\Rpc\Bulk\BulkController' => [
                'entity_class' => 'Application\Entity',
                'object_manager' => 'doctrine.object-manager.default',
                'hydrator' => 'Application\Hydrator\Entity',
                'listeners' => [
                    // Custom ListenerAggregates
                ],
            ],
        ],
    ],

    // Flag the new controller as a RPC controller:
    'zf-rpc' => [
        'Api\V1\Rpc\Bulk\BulkController' => array(
            'http_methods' => array(
                0 => 'POST',
            ),
            'route_name' => 'api.rpc.bulk',
            'service_name' => 'Bulk',
        ),
    ],

    // Enable versioning
    'zf-versioning' => [
        'uri' => [
            0 => 'api.rpc.bulk',
        ],
    ],

    // Add JSON to content negotiation
    'zf-content-negotiation' => [
        'controllers' => [
            'Api\V1\Rpc\Bulk\BulkController' => 'Json',
        ],
        'accept_whitelist' => [
            'Api\V1\Rpc\Bulk\BulkController' => array(
                0 => 'application/json',
                1 => 'application/*+json',
            ),
        ],
        'content_type_whitelist' => [
            'Api\V1\Rpc\Bulk\BulkController' => [
                0 => 'application/json',
            ],
        ],
    ],
];
```

### Create a RPC Controller class

[](#create-a-rpc-controller-class)

```
namespace Api\V1\Rpc\Bulk;
use Phpro\Apigility\Doctrine\Bulk\Controller\BulkController as BaseController;

class BulkController extends BaseController
{

}
```

Run a bulk call
===============

[](#run-a-bulk-call)

```
POST /api/bulk

```

Request body:
-------------

[](#request-body)

```
[
    {'create': {'name': 'VeeWee'}},
    {'update': {'id': 1, 'name': 'Updated'}},
    {'delete': {'id': 2}},
    {'changeEmail': {'id': 1, 'email': 'new@email.com'}},
]
```

Response body:
--------------

[](#response-body)

```
[
    {'command': 'create', 'id': 100, 'params': [], 'isSuccess': true, 'isError': false, 'error': ''},
    {'command': 'update', 'id': 1, 'params': [], 'isSuccess': true, 'isError': false, 'error': ''},
    {'command': 'delete', 'id': 2, 'params': [], 'isSuccess': true, 'isError': false, 'error': ''},
    {'command': 'changeEmail', 'id': 1, 'params': {'old-email': 'old@email.com'}, 'isSuccess': true, 'isError': false, 'error': ''},
]
```

Custom Commands
===============

[](#custom-commands)

It is very easy to add a custom action like `changeEmail` to the bulk service. This method will call the changeEmail($email) method on the entity with ID 1 and save the entity to the database. When the result of this method is an array, then these results are added as key-value pairs to the response.

Custom listeners
================

[](#custom-listeners)

It is possible to add your own custom listeners for specific tasks. You should create a class that implements ListenerAggregateInterface. This listener should listen to a BulkEvent with a specified command name. When you add this listener to the service manager, it is posible to add the key to the `listeners` property of the `doctrine-bulk-handlers` part in the configuration.

TODO
====

[](#todo)

- Interaction with admin

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.1% 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 ~109 days

Recently: every ~118 days

Total

6

Last Release

3805d ago

### Community

Maintainers

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

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (27 commits)")[![stefliekens](https://avatars.githubusercontent.com/u/3245491?v=4)](https://github.com/stefliekens "stefliekens (2 commits)")

---

Tags

doctrinemodulezf2apigilitybulk

### Embed Badge

![Health badge](/badges/phpro-zf-apigility-doctrine-bulk/health.svg)

```
[![Health](https://phpackages.com/badges/phpro-zf-apigility-doctrine-bulk/health.svg)](https://phpackages.com/packages/phpro-zf-apigility-doctrine-bulk)
```

###  Alternatives

[hounddog/doctrine-data-fixture-module

Zend Framework 2 Module that provides Doctrine Data-Fixture functionality

37335.4k9](/packages/hounddog-doctrine-data-fixture-module)[mamuz/mamuz-blog

Provides blog feature for ZF2 with Doctrine

101.1k1](/packages/mamuz-mamuz-blog)

PHPackages © 2026

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