Download the PHP package componenta/http-throttle-middleware without Composer

On this page you can find all versions of the php package componenta/http-throttle-middleware. 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 http-throttle-middleware

Componenta HTTP Throttle Middleware

PSR-15 fixed-window rate limiting middleware. It limits requests per key and adds rate limit headers to successful responses or returns 429 Too Many Requests.

Use this package when an HTTP pipeline needs a simple fixed-window request limit by client IP, user id, API key, or another application-defined key.

Boundary

This package only enforces request rate limits. It does not authenticate users, resolve trusted proxy headers, or provide a global config provider. If the application runs behind a proxy, place componenta/http-trusted-proxy-middleware before this middleware so the client_ip request attribute is available.

Installation

This package has no config provider. Register a limiter and middleware explicitly.

Limiters

Class Storage
CacheRateLimiter PSR-16 cache.
FileRateLimiter Filesystem directory.

Both implement RateLimiterInterface::hit(string $key, int $limit, int $window): RateLimitResult.

CacheRateLimiter works with any PSR-16 cache, but PSR-16 does not provide atomic increments. Under high concurrency a few extra requests can pass through between read and write. Use a backend-specific limiter if strict atomicity is required.

FileRateLimiter stores one lock-protected file per key in a writable directory. If it cannot open or lock a file, it fails open and allows the request instead of breaking the application request.

RateLimitResult contains:

Property Meaning
allowed Whether the request may continue.
limit Maximum requests in the current window.
remaining Remaining requests in the current window.
retryAfter Seconds until the window resets.

Middleware

By default the key is client_ip request attribute or REMOTE_ADDR. A custom key resolver can use user id, API key, or another identifier.

Per-route overrides can be passed through the rate_limit request attribute with limit and window keys.

Successful responses receive X-RateLimit-Limit and X-RateLimit-Remaining headers. Rejected responses have status 429, body 429 Too Many Requests, and headers Retry-After, X-RateLimit-Limit, and X-RateLimit-Remaining: 0.


All versions of http-throttle-middleware with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
psr/http-message Version ^2.0
psr/http-server-middleware Version ^1.0
psr/simple-cache Version ^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 componenta/http-throttle-middleware contains the following files

Loading the files please wait ...