PHPackages                             idealizetecnologia/circuit-breaker-php - 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. idealizetecnologia/circuit-breaker-php

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

idealizetecnologia/circuit-breaker-php
======================================

Circuit Breaker for PHP

2.0.2(6y ago)032.3k↓50%MITPHPPHP &gt;=7.1

Since Jun 30Pushed 6y agoCompare

[ Source](https://github.com/idealizetecnologia/circuit-breaker-php)[ Packagist](https://packagist.org/packages/idealizetecnologia/circuit-breaker-php)[ RSS](/packages/idealizetecnologia-circuit-breaker-php/feed)WikiDiscussions master Synced 1mo ago

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

PHP implementation of Circuit Breaker Pattern
=============================================

[](#php-implementation-of-circuit-breaker-pattern)

[![Build Status](https://camo.githubusercontent.com/e089ae8f30fa6883066a69a5a3d255041ecae54186c6b193baa435feb65914df/68747470733a2f2f7472617669732d63692e6f72672f6c656f6361726d6f2f636972637569742d627265616b65722d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/leocarmo/circuit-breaker-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e123f640be621e15fdf4422fde830bd57ed24d805f89ec286b4ff95bff16b85f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656f6361726d6f2f636972637569742d627265616b65722d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/leocarmo/circuit-breaker-php/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/3836bd348e163bc60cb11305054139aef0160fc2077a8130267df6c942920ee8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656f6361726d6f2f636972637569742d627265616b65722d7068702f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Total Downloads](https://camo.githubusercontent.com/a3e6427005a8bc8ed733771ebb3b817fa41a8efa6f211b0a2e94f0e16270966d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c656f6361726d6f2f636972637569742d627265616b65722d7068702e737667)](https://packagist.org/packages/leocarmo/circuit-breaker-php)

For more information about this pattern see [this](https://martinfowler.com/bliki/CircuitBreaker.html).

> This implementation has only redis adapter yet

Starting with composer
----------------------

[](#starting-with-composer)

`composer require leocarmo/circuit-breaker-php`

Redis adapter
-------------

[](#redis-adapter)

The first argument is a redis connection, the second is your product name, for redis namespace avoid key conflicts with another product using the same redis.

```
use LeoCarmo\CircuitBreaker\CircuitBreaker;

// Connect to redis
$redis = new \Redis();
$redis->connect('localhost', 6379);

$adapter = new \LeoCarmo\CircuitBreaker\Adapters\RedisAdapter($redis, 'my-product');

// Set redis adapter for CB
CircuitBreaker::setAdapter($adapter);
```

Set circuit break settings
--------------------------

[](#set-circuit-break-settings)

> This is not required, default values ​​will be set

```
// Configure settings for CB
CircuitBreaker::setGlobalSettings([
  'timeWindow' => 60, // Time for an open circuit (seconds)
  'failureRateThreshold' => 50, // Fail rate for open the circuit
  'intervalToHalfOpen' => 30, // Half open time (seconds)
]);
```

Configure settings for specific service
---------------------------------------

[](#configure-settings-for-specific-service)

```
// Configure settings for specific service
CircuitBreaker::setServiceSettings('my-custom-service', [
  'timeWindow' => 30, // Time for an open circuit (seconds)
  'failureRateThreshold' => 15, // Fail rate for open the circuit
  'intervalToHalfOpen' => 10, // Half open time (seconds)
]);
```

Check if circuit is available (closed)
--------------------------------------

[](#check-if-circuit-is-available-closed)

Each check is for a specific service. So you can have multiple services in the same application, and when one circuit is open, the other works normally.

```
// Check circuit status for service: `my-service`
if (! CircuitBreaker::isAvailable('my-service')) {
  die('Circuit is not available!');
}
```

Record success and failure
--------------------------

[](#record-success-and-failure)

```
// Usage example for success and failure
try {
  Service::execute('something');
  CircuitBreaker::success('my-service');
} catch (\ServiceException $e) {
  CircuitBreaker::failure('my-service');
  die($e->getMessage());
}
```

Credits
-------

[](#credits)

- [Leonardo Carmo](https://github.com/leocarmo)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

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

Total

4

Last Release

2409d ago

Major Versions

1.0.0 → 2.0.02019-06-30

PHP version history (2 changes)1.0.0PHP &gt;=7

2.0.0PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![leocarmo](https://avatars.githubusercontent.com/u/21243754?v=4)](https://github.com/leocarmo "leocarmo (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/idealizetecnologia-circuit-breaker-php/health.svg)

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

###  Alternatives

[symfony/scheduler

Provides scheduling through Symfony Messenger

8810.8M52](/packages/symfony-scheduler)[ericmann/sessionz

PHP Session Manager Interface

585.0k2](/packages/ericmann-sessionz)

PHPackages © 2026

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