PHPackages                             ylnwqm/hyperf-batch - 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. ylnwqm/hyperf-batch

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

ylnwqm/hyperf-batch
===================

insert and update batch(bulk) in Hyperf

1.0.1(3y ago)37911MITPHPPHP &gt;=7.3

Since May 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ylnwqm/hyperf-batch)[ Packagist](https://packagist.org/packages/ylnwqm/hyperf-batch)[ RSS](/packages/ylnwqm-hyperf-batch/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (3)Used By (0)

hyperf BATCH (BULK)
===================

[](#hyperf-batch-bulk)

Insert and update batch (bulk) in hyperf

From
====

[](#from)

modify from mavinoo/laravel-batch,a coroutine-based

Install
=======

[](#install)

`composer require ylnwqm/hyperf-batch`

Example Update 1
================

[](#example-update-1)

```
use App\Models\User;

$userInstance = new User;
$value = [
     [
         'id' => 1,
         'status' => 'active',
         'nickname' => 'Mohammad'
     ] ,
     [
         'id' => 5,
         'status' => 'deactive',
         'nickname' => 'Ghanbari'
     ] ,
];
$index = 'id';

Batch::update($userInstance, $value, $index);
```

Example Update 2
================

[](#example-update-2)

```
use App\Models\User;

$userInstance = new User;
$value = [
     [
         'id' => 1,
         'status' => 'active'
     ],
     [
         'id' => 5,
         'status' => 'deactive',
         'nickname' => 'Ghanbari'
     ],
     [
         'id' => 10,
         'status' => 'active',
         'date' => Carbon::now()
     ],
     [
         'id' => 11,
         'username' => 'mavinoo'
     ]
];
$index = 'id';

Batch::update($userInstance, $value, $index);
```

Example Increment / Decrement
=============================

[](#example-increment--decrement)

```
use App\Models\User;

$userInstance = new User;
$value = [
     [
         'id' => 1,
         'balance' => ['+', 500] // Add
     ] ,
     [
         'id' => 2,
         'balance' => ['-', 200] // Subtract
     ] ,
     [
         'id' => 3,
         'balance' => ['*', 5] // Multiply
     ] ,
     [
         'id' => 4,
         'balance' => ['/', 2] // Divide
     ] ,
     [
         'id' => 5,
         'balance' => ['%', 2] // Modulo
     ] ,
];
$index = 'id';

Batch::update($userInstance, $value, $index);
```

Example Insert
==============

[](#example-insert)

```
use App\Models\User;

$userInstance = new User;
$columns = [
     'firstName',
     'lastName',
     'email',
     'isActive',
     'status',
];
$values = [
     [
         'Mohammad',
         'Ghanbari',
         'emailSample_1@gmail.com',
         '1',
         '0',
     ] ,
     [
         'Saeed',
         'Mohammadi',
         'emailSample_2@gmail.com',
         '1',
         '0',
     ] ,
     [
         'Avin',
         'Ghanbari',
         'emailSample_3@gmail.com',
         '1',
         '0',
     ] ,
];
$batchSize = 500; // insert 500 (default), 100 minimum rows in one query

$result = Batch::insert($userInstance, $columns, $values, $batchSize);
```

```
// result : false or array

sample array result:
Array
(
    [totalRows]  => 384
    [totalBatch] => 500
    [totalQuery] => 1
)
```

Helper batch()
==============

[](#helper-batch)

```
// ex: update

$result = batch()->update($userInstance, $value, $index);

// ex: insert

$result = batch()->insert($userInstance, $columns, $values, $batchSize);
```

Tests
=====

[](#tests)

If you don't have phpunit installed on your project, first run `composer require phpunit/phpunit`

In the root of your hyperf app, run `./vendor/bin/phpunit ./vendor/ylnwqm/hyperf-batch/tests`

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

1427d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40aeed548983559d0bada87a34a50b031088f191d98e7956a6017cb4ca53efdb?d=identicon)[ylnwqm](/maintainers/ylnwqm)

---

Top Contributors

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

---

Tags

phphyperf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ylnwqm-hyperf-batch/health.svg)

```
[![Health](https://phpackages.com/badges/ylnwqm-hyperf-batch/health.svg)](https://phpackages.com/packages/ylnwqm-hyperf-batch)
```

###  Alternatives

[reasno/fastmongo

mongodb driver via hyperf/gotask

8975.3k1](/packages/reasno-fastmongo)[hyperf/database-pgsql

A pgsql handler for hyperf/database.

12321.2k21](/packages/hyperf-database-pgsql)[sy-records/thrift2-hbase

thrift for ali hbase+

1632.8k](/packages/sy-records-thrift2-hbase)[jonas-elias/hyperf-oracle

A oracle handler for hyperf/database.

102.5k](/packages/jonas-elias-hyperf-oracle)

PHPackages © 2026

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