PHPackages                             jdavidbakr/multi-server-event - 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. jdavidbakr/multi-server-event

Abandoned → [laravel/laravel:5.6](/?search=laravel%2Flaravel%3A5.6)Library[Utility &amp; Helpers](/categories/utility)

jdavidbakr/multi-server-event
=============================

This package extends Laravel's native Command Event class to allow for managing events fired on the same system with multiple servers, preventing an event from firing more than once

2.0.5(8y ago)37176.7k—8.6%17MITPHPPHP &gt;=5.5.9

Since Aug 11Pushed 8y ago3 watchersCompare

[ Source](https://github.com/jdavidbakr/MultiServerEvent)[ Packagist](https://packagist.org/packages/jdavidbakr/multi-server-event)[ RSS](/packages/jdavidbakr-multi-server-event/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (17)Used By (0)

Multi Server Event
==================

[](#multi-server-event)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6f9dd42adcae688d61f632a6870bbdcef618aad627ac6eabf2e520022468314a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a646176696462616b722f6d756c74692d7365727665722d6576656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jdavidbakr/multi-server-event)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/dfb307e1b21285c75382bebe868f4694f71a90ef815e8f465557f98afb68b62b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a646176696462616b722f6d756c74692d7365727665722d6576656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jdavidbakr/multi-server-event)

This package extends Laravel's native Event class to include the ability to block events from occurring aross multiple servers, as would be the case if you have a laravel instance behind a load balancer in an auto-scaling situation.

It uses a database table to track the currently running process, and each server generates a unique key to lock the command. In order to prevent a condition where a short-running command's lock doesn't last long enough, we are implementing a minimum 10 second break between the completion of the command and its next execution time, so if a command runs every minute but takes between 50 and 59 seconds to complete, the next command will be delayed one more minute.

NOTE: Laravel 5.6 now contains a function `onOneServer()` that solves the issue that this package was built to fix. Therefore, it is recommended that you use the core function instead of this package.
========================================================================================================================================================================================================

[](#note-laravel-56-now-contains-a-function-ononeserver-that-solves-the-issue-that-this-package-was-built-to-fix-therefore-it-is-recommended-that-you-use-the-core-function-instead-of-this-package)

#### For Laravel &lt; 5.4, please use version 1.X

[](#for-laravel--54-please-use-version-1x)

#### Upgrading from version 1.X

[](#upgrading-from-version-1x)

If upgrading from version 1.X, please note the change in the defineConsoleSchedule() command in app\\Console\\Kernel.php.

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

[](#installation)

```
$ composer require jdavidbakr/multi-server-event

```

The new event structure uses a database table to track which server is currently executing an event. You must create the database table using the provided migration. To do this, add the following to the $commands array in \\App\\Console\\Kernel.php:

```
\jdavidbakr\MultiServerEvent\Commands\MultiServerMigrationService::class,
```

then perform the migration

```
php artisan make:migration:multi-server-event
php artisan migrate

```

Now we want to change the default schedule IoC to use this alternate one. In app\\Console\\Kernel.php add the following function:

```
/**
 * Define the application's command schedule.
 *
 * @return void
 */
protected function defineConsoleSchedule()
{
    $this->app->instance(
        Schedule::class,
        $schedule = new \jdavidbakr\MultiServerEvent\Scheduling\Schedule()
    );

    $this->schedule($schedule);
}
```

Usage
-----

[](#usage)

When composing your schedule, simply add "withoutOverlappingMultiServer()" to the command, i.e.

```
$schedule->command('inspire')
    ->daily()
    ->withoutOverlappingMultiServer();
```

This will prevent multiple servers from executing the same event at the same time.

When composing your schedule, you can also ensure that cron is not stuck, simply add "ensureFinishedMultiServer()" to the command, i.e.

```
$schedule->command('inspire')
    ->daily()
    ->withoutOverlappingMultiServer()
    ->ensureFinishedMultiServer(30);
```

This will prevent from stuck commands during lost connection or deployment. Note, choose time to be enough to mark as "stuck", fox example, long running command should have bigger tolerance time. You can track such events how ofter it happens by binding listeners on `EnsureCleanUpExecuted` event

Testing
-------

[](#testing)

```
phpunit

```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~65 days

Recently: every ~92 days

Total

15

Last Release

3019d ago

Major Versions

1.0.6 → 2.0.02017-02-02

1.0.8 → 2.0.22017-05-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/28fc80e04726581ef8fd2cda5300c45a22d67437c62bbaa7be372feb46256640?d=identicon)[jdavidbakr](/maintainers/jdavidbakr)

---

Top Contributors

[![jdavidbakr](https://avatars.githubusercontent.com/u/25177?v=4)](https://github.com/jdavidbakr "jdavidbakr (12 commits)")[![pulkitjalan](https://avatars.githubusercontent.com/u/4124930?v=4)](https://github.com/pulkitjalan "pulkitjalan (2 commits)")[![investonline](https://avatars.githubusercontent.com/u/20278343?v=4)](https://github.com/investonline "investonline (1 commits)")

---

Tags

schedulerlaravelload balancingMulti-Server

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdavidbakr-multi-server-event/health.svg)

```
[![Health](https://phpackages.com/badges/jdavidbakr-multi-server-event/health.svg)](https://phpackages.com/packages/jdavidbakr-multi-server-event)
```

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4205.3M84](/packages/livewire-volt)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)[edofre/laravel-fullcalendar-scheduler

Laravel component for fullcalendar scheduler module

251.5k](/packages/edofre-laravel-fullcalendar-scheduler)

PHPackages © 2026

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