PHPackages                             nasservb/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nasservb/laravel-bulk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nasservb/laravel-bulk
=====================

Provide Bulk operation for Laravel

00PHP

Since Dec 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/nasservb/laravel-bulk)[ Packagist](https://packagist.org/packages/nasservb/laravel-bulk)[ RSS](/packages/nasservb-laravel-bulk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Bulk Operation Tool
===========================

[](#laravel-bulk-operation-tool)

[![Latest Stable Version](https://camo.githubusercontent.com/00500e28440cbccb8be3f9c38e0186d527a2a2392111b4b28f4f62eb2702da58/68747470733a2f2f706f7365722e707567782e6f72672f6e617373657276622f6c61726176656c2d62756c6b2f76)](//packagist.org/packages/nasservb/laravel-bulk) [![Total Downloads](https://camo.githubusercontent.com/a5dabecb7655840ff028f7a488c246c95d35a0807ea22ff3b67b8ad43489b04a/68747470733a2f2f706f7365722e707567782e6f72672f6e617373657276622f6c61726176656c2d62756c6b2f646f776e6c6f616473)](//packagist.org/packages/nasservb/laravel-bulk) [![License](https://camo.githubusercontent.com/e71e2f1741a9da145e55609c2f8820916d9aad4e17875f8a56956e8482ff2f94/68747470733a2f2f706f7365722e707567782e6f72672f6e617373657276622f6c61726176656c2d62756c6b2f6c6963656e7365)](//packagist.org/packages/nasservb/laravel-bulk)

This package provides Bulk operation for Laravel projects.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Usage](#usage)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can install the package via composer:

```
composer require nasservb/laravel-bulk
```

Laravel will automatically register the package service provider.

#### Install redis client

[](#install-redis-client)

For use this library we recomend using the latest version of Redis at this time `(^6)`

```
composer require predis/predis
```

### Setting up Redis configuration

[](#setting-up-redis-configuration)

After you've published the Laravel Bulk package configuration, you need to set your driver to `Redis` and add its configuration:

```
// .env
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
```

Usage
-----

[](#usage)

### What's the Problem and How to solve it?

[](#whats-the-problem-and-how-to-solve-it)

when you need to save data to the DB, and this data is obtained over time such as page visit count or the number of like, it is not a good idea to insert data into the database for each request.

We can use Redis to cache this data, and when the number of items reaches a significant amount, read the data from Redis and save it to DB via a bulk insert query.

This PR helps us to do this simply in a few lines of code for saving visits:

```
	app('bulk')
	    ->name('page-visit')
	    ->add(request()->ip())
	    ->then(function($visits)use($page){
		$page->visits()->attach($visits);
	    });
```

or for saving likes:

```
	app('bulk')
	    ->name('like-count')
            ->add(auth()->id())
            ->then(function ($likes) use ($post) {
                $post->likes()->sync($likes);
            });
```

### How does this work internally?

[](#how-does-this-work-internally)

- This code uses the Redis RPUSH command to add data to the cache,
- Check cache size with Redis LLEN command,
- And when the cache is full, release them with the Redis LRANGE command and delete the cache items with the Redis DEL command.

### What are the benefits?

[](#what-are-the-benefits)

If you have a direct insert in each request and replace it with the Redis::bulk function, your performance will be 10 times better in the default configuration. you can configure your cache size with:

```
	app('bulk')
	    ->name('name')
            ->count(cache_size);
            ...
```

for saving likes:

```
	app('bulk')
	    ->name('like-count')
            ->add(auth()->id())
            ->count(100)
            ->then(function ($likes) use ($post) {
                $post->likes()->sync($likes);
            });
```

### How to extract cache data?

[](#how-to-extract-cache-data)

And improve the performance again, but keep in mind that when the cache is large, saving your data will be delayed until the cache is full and remains in memory.

When the execution of your code is going to finish, you need to release data from the cache and save it to DB.

To do this, you can use the forceRelease function as follows:

```
	app('bulk')
	    ->name('like-count')
            ->forceRelease()
            ->then(function ($likes) use ($post) {
                $post->likes()->sync($likes);
            });
```

You can add this code in Application::shutdown() function or any other place that runs at the end.

Limitations
-----------

[](#limitations)

it's depend on cach size and redis capablility.

Credits
-------

[](#credits)

- [Nasser Niazy](https://github.com/nasservb)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/365ecfe86edc686352a73f553230b9d1105e8223a24314e311e5c804df968531?d=identicon)[nasservb](/maintainers/nasservb)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/nasservb-laravel-bulk/health.svg)

```
[![Health](https://phpackages.com/badges/nasservb-laravel-bulk/health.svg)](https://phpackages.com/packages/nasservb-laravel-bulk)
```

###  Alternatives

[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)

PHPackages © 2026

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