PHPackages                             bvtterfly/laravel-circuit-breaker - 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. bvtterfly/laravel-circuit-breaker

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

bvtterfly/laravel-circuit-breaker
=================================

Laravel circuit breaker package

0.1.0(4y ago)4210.0k↓20%8[4 PRs](https://github.com/bvtterfly/laravel-circuit-breaker/pulls)MITPHPPHP ^8.0

Since Mar 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bvtterfly/laravel-circuit-breaker)[ Packagist](https://packagist.org/packages/bvtterfly/laravel-circuit-breaker)[ Docs](https://github.com/bvtterfly/laravel-circuit-breaker)[ GitHub Sponsors](https://github.com/bvtterfly)[ RSS](/packages/bvtterfly-laravel-circuit-breaker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (5)Used By (0)

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨

I no longer use Laravel and cannot justify the time needed to maintain this package. That's why I have chosen to abandon it. Feel free to fork my code and maintain your own copy.

Laravel Circuit Breaker
=======================

[](#laravel-circuit-breaker)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8e616bf82fac8668c1d4ca20c3091010792df87b2a311115c3d28a7dacf38123/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627674746572666c792f6c61726176656c2d636972637569742d627265616b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bvtterfly/laravel-circuit-breaker) [![GitHub Tests Action Status](https://camo.githubusercontent.com/a0b6d89467341c5bb018100cd405213e5483f74aa14507d4ea94f3283806d533/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f627674746572666c792f6c61726176656c2d636972637569742d627265616b65722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/bvtterfly/laravel-circuit-breaker/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://camo.githubusercontent.com/5a75393764f8edc1a678452849a1138cf4afa013b84b12c3cf4e758ce2b0a1d1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f627674746572666c792f6c61726176656c2d636972637569742d627265616b65722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/bvtterfly/laravel-circuit-breaker/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain) [![Total Downloads](https://camo.githubusercontent.com/aea91dfffc69f8300ce5d2bdd01ef3d79300abc559d6f2159aedfa0aa2479ab0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627674746572666c792f6c61726176656c2d636972637569742d627265616b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bvtterfly/laravel-circuit-breaker)

This package is a simple implementation of circuit breaker pattern for laravel. It protects your application from failures of its service dependencies.

Resources about the circuit breaker pattern:

-
-

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

[](#installation)

You can install the package via composer:

```
composer require bvtterfly/laravel-circuit-breaker
```

You can publish the config file with:

```
php artisan vendor:publish --tag="circuit-breaker-config"
```

This is the contents of the published config file:

```
return [
    // Here you may specify which of your cache stores you wish to use as your default store.
    'store' => config('cache.default'),

    // length of interval (in seconds) over which it calculates the error rate
    'time_window' => 60,

    // the number of errors to encounter within a given timespan before opening the circuit
    'error_threshold' => 10,

    // the amount of time until the circuit breaker will try to query the resource again
    'error_timeout' => 300,

    // the timeout for the circuit when it is in the half-open state
    'half_open_timeout' => 150,

    // the amount of consecutive successes for the circuit to close again
    'success_threshold' => 1,
];
```

Usage
-----

[](#usage)

Your application may have multiple services, so you will have to get a circuit breaker for each service:

```
use Bvtterfly\LaravelCircuitBreaker\Facades\CircuitBreaker;
$circuit = CircuitBreaker::service('my-service');
// or you can override default configuration:
$circuit = CircuitBreaker::service('my-service', [
    'time_window' => 120,
    'success_threshold' => 3,
]);
```

#### Three states of circuit breaker

[](#three-states-of-circuit-breaker)

[![](https://user-images.githubusercontent.com/1885716/53690408-4a7f3d00-3dad-11e9-852c-0e082b7b9636.png)](https://user-images.githubusercontent.com/1885716/53690408-4a7f3d00-3dad-11e9-852c-0e082b7b9636.png)

You can then determine whether a service is available or not.

```
// Check circuit status for service
if (! $circuit->isAvailable()) {
    // Service isn't available
}
```

Service is available if it's CLOSED or HALF\_OPEN. Then, you should call your service, depending on the response. You can mark it as a success or failure to update the circuit status.

```
try {
    callAPI();
    $circuit->markSuccess();
} catch (\Exception $e) {
    // If an error occurred, it must be recorded as failed.
    $circuit->markFailed();
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [ARI](https://github.com/bvtterfly)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

1532d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/99682351?v=4)[Λгi](/maintainers/bvtterfly)[@bvtterfly](https://github.com/bvtterfly)

---

Top Contributors

[![bvtterfly](https://avatars.githubusercontent.com/u/99682351?v=4)](https://github.com/bvtterfly "bvtterfly (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")

---

Tags

laravelbvtterflylaravel-circuit-breaker

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/bvtterfly-laravel-circuit-breaker/health.svg)

```
[![Health](https://phpackages.com/badges/bvtterfly-laravel-circuit-breaker/health.svg)](https://phpackages.com/packages/bvtterfly-laravel-circuit-breaker)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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