PHPackages                             ob-ivan/throttler - 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. ob-ivan/throttler

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

ob-ivan/throttler
=================

Execute tasks in a loop at limited rate.

v1.0(8y ago)023[1 issues](https://github.com/ob-ivan/throttler/issues)PHPCI failing

Since Feb 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ob-ivan/throttler)[ Packagist](https://packagist.org/packages/ob-ivan/throttler)[ RSS](/packages/ob-ivan-throttler/feed)WikiDiscussions master Synced 2d ago

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

Throttler
=========

[](#throttler)

Execute tasks in a loop at limited rate.

This answers a question on StackOverflow:

Other implementations of the same idea you may want to have a look at:

-
-
-

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

[](#installation)

```
composer require ob-ivan/throttler

```

Usage
-----

[](#usage)

Suppose you want to send requests to an API based on data from DB, but the API only allows 100 requests per minute.

You can use a throttler to do that like this:

```
use Ob_Ivan\Throttler\Throttler;

$throttler = new Throttler(
    100, // number of requests
    60 // number of seconds in a unit of time
);
$throttler->run($job);
```

The `$job` variable here stands for your implementation of `JobInterface`:

```
use Ob_Ivan\Throttler\JobInterface;

class MyAwesomeJob implements JobInterface {
    private $id;
    private $requestData;
    private $responseData = [];

    /**
     * Advance the job to the next piece and tell if there is any.
     *
     * Prefetch the data to be sent on job execution.
     * This way execution time will not be wasted on data fetching.
     *
     * @return bool True to continue execution. False to exit the loop.
     */
    public function next(): bool {
        ++$id;
        $row = $this->getRow($id);
        if ($row) {
            $this->requestData = $this->makeRequestData($row);
            return true;
        } else {
            return false;
        }
    }

    /**
     * Perform the action the job is designed for.
     *
     * No return value is expected from this method.
     * We rely on side effects to retrieve the response data.
     */
    public function execute() {
        $response = $this->requestApi($this->requestData);
        $this->responseData[] = $this->extractResponseData($response);
    }

    // ...
}
```

And that's it.

Development
-----------

[](#development)

To install phpunit locally:

```
composer install

```

To run tests:

```
vendor/bin/phpunit

```

License
-------

[](#license)

MIT

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

3017d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16bf08194a92f7509a08dfffd03540b37680b368041f74a5c4f82788cace2037?d=identicon)[ob-ivan](/maintainers/ob-ivan)

---

Top Contributors

[![ob-ivan](https://avatars.githubusercontent.com/u/1832804?v=4)](https://github.com/ob-ivan "ob-ivan (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ob-ivan-throttler/health.svg)

```
[![Health](https://phpackages.com/badges/ob-ivan-throttler/health.svg)](https://phpackages.com/packages/ob-ivan-throttler)
```

###  Alternatives

[ichhabrecht/content-defender

Define allowed or denied content element types in your backend layouts

892.9M22](/packages/ichhabrecht-content-defender)[teamones/casbin

Teamones框架 casbin sdk

101.8k](/packages/teamones-casbin)

PHPackages © 2026

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