Download the PHP package nimbly/throttler without Composer

On this page you can find all versions of the php package nimbly/throttler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package throttler

Throttler

Latest Stable Version Build Status License

A framework agnostic request rate limiter.

Description

Throttler can rate limit on any data point you like: IP address, user ID, API key, or any other uniquely identifying information you have access to.

Installation

Usage

Storage adapter

You need a place to keep track of the hit counters - cache, database, or whatever. Create an instance of a storage adapter to be passed into the Throttler. See the Available storage adapters section further down for complete list of adapters.

Throttler

Instantiate Throttler by passing in a storage adapter instance.

Constructor Options

You may pass in an array of key => value pair options as the second parameter of the constructor.

Supported options:

Methods

Log a hit on the throttler incrementing the rate limit counter. Returns true on success and false on failure.

This example allows 120 requests in a 60 second timespan per IP address.


Check (but do not increment) the current rate limit counter for the given ID.

Middleware

Add the throttler to your Middleware (you're using Middleware, right?)

Available storage adapters

The following list of storage adapters are provided "out of the box":

Redis

Requires the Predis library available via predis/predis on Packagist.

Database

The database adapter can use any PDO compatible database to persist throttler data. Just add this table to your database:

You can also customize the columns that the Throttler will use along with garbage collection chance:

APCu

APCu is an in-memory PHP cache and requires the PECL APCu library available through most Linux package managers.

Memory

The memory adapter maintains its throttler purely in memory and does not persist its data between HTTP or CLI requets. This adapter is ideal for testing or other special use cases. Only use this adapter if you know what you are doing.

Custom storage adapters

A interface is provided so that you may create your own adapters for any persistance engine you want. It must implement two methods:

Returns the given key's current counter or 0 if key does not exist.


Increments the counter for the given key. If key does not exist, it must create it and set its counter to 1 as well as set the counter to expire after $decay seconds. Returns the counter value.


All versions of throttler with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nimbly/throttler contains the following files

Loading the files please wait ....