PHPackages                             los/cerberus - 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. los/cerberus

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

los/cerberus
============

Circuit Breaker pattern implementation in PHP

1.0.0(6y ago)15.2k1MITPHPPHP ^7.2

Since Jun 24Pushed 6y agoCompare

[ Source](https://github.com/Lansoweb/cerberus)[ Packagist](https://packagist.org/packages/los/cerberus)[ Docs](https://github.com/mt-olympus/cerberus)[ RSS](/packages/los-cerberus/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (1)

Cerberus
========

[](#cerberus)

[![Build Status](https://camo.githubusercontent.com/497711574efc3abc0a87fcfc522ab97d1daec641ccdc23b9ebc81c171595de5c/68747470733a2f2f7472617669732d63692e6f72672f6c616e736f7765622f63657262657275732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lansoweb/cerberus) [![Coverage Status](https://camo.githubusercontent.com/365f36e4e09c1073fb6727a97d2033c1cee6dbff3d86908abc32fdafd48c038a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f4c616e736f7765622f63657262657275732f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/Lansoweb/cerberus?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/5674adfc6372bdd33be9c36690580406654040cd806e44247cc9a552f452ed45/68747470733a2f2f706f7365722e707567782e6f72672f6c6f732f63657262657275732f762f737461626c652e737667)](https://packagist.org/packages/los/cerberus) [![Total Downloads](https://camo.githubusercontent.com/bac7d073e7f61d4168cee6b8a7d5e5ae69e89e710d840a482006bcc613883c72/68747470733a2f2f706f7365722e707567782e6f72672f6c6f732f63657262657275732f646f776e6c6f6164732e737667)](https://packagist.org/packages/los/cerberus)

Introduction
------------

[](#introduction)

This is a Circuit Breaker pattern implementation in PHP.

This library helps you to handle external services timeouts and outages.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2
- Any cache library implementing psr/simple-cache

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

[](#installation)

```
composer require los/cerberus:^1.0

```

Configuration
-------------

[](#configuration)

You can manually create a Cerberus instance or use a Factory

### Factory

[](#factory)

```
'factories' => [
    Los\Cerberus\Cerberus::class => Los\Cerberus\CerberusFactory::class
],
```

and copy the configuration file config/cerberus.global.php.dist to your config/autoload/cerberus.global.php and change to your needs.

```
return [
    'cerberus' => [
        'max_failures' => 5,
        'timeout' => 60,
    ]
];
```

The `maxFailure` parameter is the number of failures after which the circuit is opened and the service becomes not available.

When the `timeout` is reached, the circuit becomes half opened and one attempt is possible and the status is updated.

The factory pull the cache from the container using

```
$container->get(\Psr\SimpleCache\CacheInterface::class)
```

so you need to have one implemented.

### Manually

[](#manually)

You can create a Cerberus instance manually:

```
$storage = new Cache(); // Any psr/simple-cache implementation
$cerberus = new Cerberus($storage, 5, 60);
```

Usage
-----

[](#usage)

The usage is simple. Each time you will access a remote resource (like an Web Service), check for its availability and report its success or failure:

```
if ($cerberus->isAvailable()) {
    try {
        $http->makeRequest();
        $cerberus->reportSuccess();
    } catch (\Exception $ex) {
        $cerberus->reportFailure();
    }
}
```

You can use Cerberus to control more than one service. In this scenario, use the methods passing a service name:

```
if ($cerberus->isAvailable('service-one')) {
    try {
        $http->makeRequest();
        $cerberus->reportSuccess('service-one');
    } catch (\Exception $ex) {
        $cerberus->reportFailure('service-one');
    }
}

if ($cerberus->isAvailable('service-two')) {
    try {
        $http->makeRequest();
        $cerberus->reportSuccess('service-two');
    } catch (\Exception $ex) {
        $cerberus->reportFailure('service-two');
    }
}
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2517d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b54dffc1ebcb317a0cf825a781ab6c5f30980e9abd0d0a3f9c68830cb05c014?d=identicon)[Lansoweb](/maintainers/Lansoweb)

---

Top Contributors

[![Lansoweb](https://avatars.githubusercontent.com/u/2109813?v=4)](https://github.com/Lansoweb "Lansoweb (9 commits)")

---

Tags

circuit-breakerphpcircuit breakercircuitbreaker

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/los-cerberus/health.svg)

```
[![Health](https://phpackages.com/badges/los-cerberus/health.svg)](https://phpackages.com/packages/los-cerberus)
```

###  Alternatives

[illuminate/contracts

The Illuminate Contracts package.

704122.9M10.1k](/packages/illuminate-contracts)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[ejsmont-artur/php-circuit-breaker

PHP Circuit Breaker component

169964.9k4](/packages/ejsmont-artur-php-circuit-breaker)[francescomalatesta/laravel-circuit-breaker

A circuit breaker pattern implementation for the Laravel framework

2919.2k2](/packages/francescomalatesta-laravel-circuit-breaker)[gabrielanhaia/laravel-circuit-breaker

Laravel integration for PHP Circuit Breaker — multiple storage drivers, middleware, Artisan commands, and event system

481.0k](/packages/gabrielanhaia-laravel-circuit-breaker)

PHPackages © 2026

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