Download the PHP package bedrockstreaming/rate-limit-bundle without Composer

On this page you can find all versions of the php package bedrockstreaming/rate-limit-bundle. 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 rate-limit-bundle

RateLimitBundle

This bundle provides an easy way to protect your project by limiting access to your controllers.

Install the bundle

Update your config/bundles.php file to add the bundle for all env

Configure the bundle

Add the _config/packages/bedrock_ratelimit.yaml file with the following data.

By default, the limitation is common to all routes annotated #[RateLimit]. For example, if you keep the default configuration and you configure the #[RateLimit] attribute in 2 routes. Limit will shared between this 2 routes, if user consume all authorized calls on the first route, the second route couldn't be called. If you swicth limit_by_route to true, users will be allowed to reach the limit on each route annotated.

#[GraphQLRateLimit]attribute allows you to rate limit by graphQL query or mutation. /!\ To use this attribute, you will need to install suggested package.

If you switch display_headers to true, 3 headers will be added x-rate-limit, x-rate-limit-hits, x-rate-limit-untils to your responses. This can be usefull to debug your limitations. display_headers is used to display a verbose return if limit is reached.

Configure your storage

You must tell Symfony which storage implementation you want to use.

Update your config/services.yml like this:

By default, only RateLimitInMemory is provided. But feel free to create your own by implementing RateLimitStorageInterface or ManuallyResetableRateLimitStorageInterface. If your database has a TTL system (like Redis), you can implement only RateLimitStorageInterface. Otherwhise you must implement also ManuallyResetableRateLimitStorageInterface to manually delete rate limit in your database.

Configure your modifiers

Modifiers are a way to customize the rate limit.

This bundle provides 2 modifiers:

Update your config/services.yml like this:

You can also create your own rate limit modifier by implementing RateLimitModifierInterface and tagging your service accordingly.

Configure your routes

With attribute

Add the #[RateLimit] attribute to your controller methods (by default, the limit will be 1000 requests per minute). This attribute accepts parameters to customize the rate limit. The following example shows how to limit requests on a route at the rate of 10 requests max every 2 minutes. :warning: This customization only works if the limit_by_route parameter is true

To rate limit your graphQL API, add the #[GraphQlRateLimit] attribute to your graphQL controller. This attribute requires a list of endpoints and accepts parameters to customize the rate limit. The following example shows how to limit requests on an endpoint at the rate of 10 requests max every 2 minutes and on default limitations.

In YAML

You also may add your rate limits in configuration files (Yaml) with the route name. If period or limit is not defined for a route, the bundle will take the common option.

Migration to php8

If you use rector you can use those rules to automatically migrate annotation to attributes :


All versions of rate-limit-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
symfony/config Version ^5.4 || ^6.0
symfony/dependency-injection Version ^5.4 || ^6.0
symfony/event-dispatcher Version ^5.4 || ^6.0
symfony/http-foundation Version ^5.4 || ^6.0
symfony/http-kernel Version ^5.4 || ^6.0
symfony/options-resolver Version ^5.4 || ^6.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 bedrockstreaming/rate-limit-bundle contains the following files

Loading the files please wait ....