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

ActiveLibrary

qujsh/laravel-breaker
=====================

08PHP

Since Jul 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/qujsh/laravel-breaker)[ Packagist](https://packagist.org/packages/qujsh/laravel-breaker)[ RSS](/packages/qujsh-laravel-breaker/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-breaker
===============

[](#laravel-breaker)

基于laravel的简易熔断器实现，

Install
-------

[](#install)

laravel5.6 以上版本

```
composer require qujsh/laravel-breaker
```

使用下面命令来生成配置文件，和注册命令行任务

```
php artisan vendor:publish --provider="Qujsh\Breaker\BreakerServiceProvider"
```

命令行定时任务监听，判断进程是否一直开启， App\\Console\\Kernel.php

```
protected function schedule(Schedule $schedule)
{
    //每分钟执行一次命令判断，使 监听程序一直开启
    $schedule->command('breaker:set-halfopen')->everyMinute();
}
```

Usage
-----

[](#usage)

自定义一个类，定义正常 handle()函数，和降级 fall()函数使程序能运行。示例：

```
namespace App\Breaker;

use Qujsh\Breaker\IService\BreakerServiceInterface;

class Breaker implements BreakerServiceInterface{

    public function handle()
    {
        // TODO: Implement handle() method.

        // success function to do something

        //throw new \Exception('test throw');
        return 'handle';
    }

    public function fall()
    {
        // TODO: Implement fall() method.

        //fall function to do, when handle() is fail

        return 'fall';
    }
}

//callback execute
$breaker = new Qujsh\Breaker\Service\Breaker();
$result = $breaker->handle(new \App\Breaker\Breaker());
```

Config
------

[](#config)

### default

[](#default)

```
return [
    'default' => [
        'attempts' => 3,           //times, when reach this value, breaker is open
        'interval' => 180,         //interval, it's time to change state from open to halfopen
    ],

    //multi array with diff key should be defined over there

    'state_open' => 1,              //breaker state open
    'state_halfopen' => 2,          //breaker state halfopen
    'state_close' => 3,             //breaker state close, default
];
```

- default：默认service，包含 attempts 和 interval，可定义多组，使用不同key值
- attempts：尝试次数，几次后开启熔断器
- interval：多久时间后转换状态为半开启， 时间单位 秒

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

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/696eed63332b394e491ede2c9a57210fa3278972e8fdd713f48fcf279e29d7dd?d=identicon)[qujsh](/maintainers/qujsh)

---

Top Contributors

[![qujsh](https://avatars.githubusercontent.com/u/13012762?v=4)](https://github.com/qujsh "qujsh (13 commits)")

### Embed Badge

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

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

PHPackages © 2026

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