Download the PHP package beheh/flaps without Composer

On this page you can find all versions of the php package beheh/flaps. 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 flaps

Flaps

Travis Scrutinizer Coverage Scrutinizer Packagist Packagist

Flaps is a modular library for rate limiting requests in PHP applications.

The library supports custom storage backends, throttling strategies and violation handlers for flexible integration into any project.

Developed by @beheh and licensed under the ISC license.

Requirements

Basic usage

Why rate limit?

There are many benefits from rate limiting your web application. At any point in time your server(s) could be hit by a huge number of requests from one or many clients. These could be:

Most of these problems can be solved in a variety of ways, for example by using a spam filter or a fully configured firewall. Rate limiting is nevertheless a basic tool for improving application security, but offers no full protection.

Advanced examples

Application-handled violation

Multiple throttling strategies

Storage

Redis

The easiest storage system to get started is Redis (via nrk/predis):

Don't forget to composer require predis/predis.

Doctrine cache

You can use any of the Doctrine cache implementations by using the DoctrineCacheAdapter:

The Doctrine caching implementations can be installed with composer require doctrine/cache.

Custom storage

Alternatively you can use your own storage system by implementing BehEh\Flaps\StorageInterface.

Throttling strategies

Leaky bucket strategy

This strategy is based on the leaky bucket algorithm. Each unique identifier of a flap corresponds to a leaky bucket. Clients can now access the buckets as much as they like, inserting water for every request. If a request would cause the bucket to overflow, it is denied. In order to allow later requests, the bucket leaks at a fixed rate.

Custom throttling strategy

Once again, you can supply your own throttling strategy by implementing BehEh\Flaps\ThrottlingStrategyInterface.

Violation handler

You can handle violations either using one of the included handlers or by writing your own.

HTTP violation handler

The HTTP violation handler is the most basic violation handler, recommended for simple scripts. It simply sends the correct HTTP header (status code 429) and die()s. This is not recommended for any larger application and should be replaced by one of the more customizable handlers.

Passive violation handler

The passive violation handler allows you to easily react to violations. limit() will return false if the requests violates any throttling strategy, so you are able to log the request or return a custom error page.

Exception violation handler

The exception violation handler can be used in larger frameworks. It will throw a ThrottlingViolationException whenever a ThrottlingStrategy is violated. You should be able to setup your exception handler to catch any ThrottlingViolationException.

Custom violation handler

The corresponding interface for custom violation handlers is BehEh\Flaps\ViolationHandlerInterface.

Default violation handler

The Flaps object can pass a default violation handler to the flaps.


All versions of flaps with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 beheh/flaps contains the following files

Loading the files please wait ....