Download the PHP package asiadevmedia/guzzle-rate-limiter without Composer
On this page you can find all versions of the php package asiadevmedia/guzzle-rate-limiter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download asiadevmedia/guzzle-rate-limiter
More information about asiadevmedia/guzzle-rate-limiter
Files in asiadevmedia/guzzle-rate-limiter
Package guzzle-rate-limiter
Short Description A rate limiter for Guzzle
License MIT
Homepage https://github.com/spatie/guzzle-rate-limiter-middleware
Informations about the package guzzle-rate-limiter
A rate limiter for Guzzle
A rate limiter middleware for Guzzle. Here's what you need to know:
- Specify a maximum amount of requests per minute or per second
- When the limit is reached, the process will
sleep
until the request can be made - Implement your own driver to persist the rate limiter's request store. This is necessary if the rate limiter needs to work across separate processes, the package ships with an
InMemoryStore
.
Installation
You can install the package via composer:
Usage
Create a Guzzle middleware stack and register it on the client.
You can create a rate limiter to limit per second or per minute.
Custom stores
By default, the rate limiter works in memory. This means that if you have a second PHP process (or Guzzle client) consuming the same API, you'd still possibly hit the rate limit. To work around this issue, the rate limiter's state should be persisted to a cache. Implement the Store
interface with your own cache, and pass the store to the rate limiter.
A Laravel example of a custom Store
:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
Postcardware
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
We publish all received postcards on our company website.
Credits
- Sebastian De Deyne
- All Contributors
License
The MIT License (MIT). Please see License File for more information.