PHPackages                             mcprohosting/flywheel - 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. mcprohosting/flywheel

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

mcprohosting/flywheel
=====================

React to rates

0.0.4(11y ago)277GPL-2.0PHPPHP &gt;=5.4.0

Since Jun 19Pushed 11y ago17 watchersCompare

[ Source](https://github.com/MCProHosting/flywheel)[ Packagist](https://packagist.org/packages/mcprohosting/flywheel)[ RSS](/packages/mcprohosting-flywheel/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

Flywheel
========

[](#flywheel)

Flywheel is a small Laravel package for reacting differently under varying levels of load. It isn't an extremely precise mechanism - it's optimized for speed and designed to hold up under rigorous circumstances (that's where it's meant to be used, after all!). Its intention is allowing the application to, under high strain such as a denial of service attack, forgo expensive but not mission-critical functionality.

It does this by storing a single string to the cache for each "flywheel". This is quite small and consists of two concatenated values, which are used to do a kind of linear regression to determine the load of the application on the interval. It's designed to be fast, not highly accurate, and to add the minimal possible overhead to the system.

Usage
-----

[](#usage)

1. Install the package with Laravel.
2. Register its service provider, `Mcprohosting\Flywheel\FlywheelServiceProvider`
3. You may wish to register its facade as an alias, `"Flywheel" => "Mcprohosting\Flywheel\Flywheel"`
4. Profit?

Factory method: **Flywheel::make(string $name, float $interval, callable|array $level)**

Instantiate a new Flywheel. `$name` is a fairly arbitrary string, just used to identify the given wheel with the cache. `$interval` should be the given interval, in seconds, that you want to "monitor" against. `$level` should be an array, with its keys being the number of calls it takes to reach that "level" and values being callables that are called at each level. For example:

```
$wheel = Flywheel::make('loadStatus', 3, array(
    0  => function ($name) { echo "Load is A-Okay, $name!"; },
    10 => function ($name) { echo "We're getting some load, $name."; },
    50 => function ($name) { echo "We have so much load, $name!"; }
));

$wheel->spin('Connor');
```

Now, if this page gets between zero and ten visitors in a period of three seconds, it'll show the first message: "Load is A-Okay, Connor!" If it gets between ten and fifty, it will likewise show the second message. Any more than that, the third message will be shown. You may have noticed that any arguments that get passed to `spin()` will be passed on as arguments to whatever is called for the current level.

You can alternately declare levels dynamically. This may be preferable, as you're able create the Wheel when the application boots, but bind the logic on where and when it is necessary.

```
$wheel = Flywheel::make('loadStatus', 3);
$wheel->addLevel(0, function ($name) { echo "Load is A-Okay, $name!"; });
$wheel->addLevel(10, function ($name) { echo "We're getting some load, $name."; });
$wheel->addLevel(50, function ($name) { echo "We have so much load, $name!"; });

$wheel->spin('Connor');
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Total

4

Last Release

4373d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6375a3210e43e05516fd8ffa377cec01888a6c3c4e4ce4130cbd0f7c0eeb0a02?d=identicon)[connor4312](/maintainers/connor4312)

---

Tags

skinminecrafthead

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mcprohosting-flywheel/health.svg)

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

###  Alternatives

[toin0u/geocoder-laravel

Geocoder Service Provider for Laravel

7615.4M17](/packages/toin0u-geocoder-laravel)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)

PHPackages © 2026

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