Download the PHP package abolaradev/livewire-rate-limiter without Composer

On this page you can find all versions of the php package abolaradev/livewire-rate-limiter. 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 livewire-rate-limiter

Livewire Rate Limiter

Rate Limiting is a technique used to control how many requests a user or client can make within a specific period of time. It helps protect applications from excessive requests, abuse, brute-force attempts, and unnecessary resource consumption.

Livewire Rate Limiter provides a simple way to apply Rate Limiting to Livewire Actions without having to implement the Rate Limiting logic manually.

Features

Installation

You can install the package via Composer:

You can publish the configuration file with:

Configuration

The package configuration is located at config/livewire-rate-limiter.php:

Usage

Using the RateLimiter Attribute

To enable Rate Limiting for a Livewire Action, simply add the RateLimiter PHP Attribute to the desired method.

By default, the RateLimiter Attribute uses the values defined in the config/livewire-rate-limiter.php configuration file.

Custom Rate Limiting

You can customize the Rate Limiting settings for a specific Livewire Action by passing values directly to the RateLimiter Attribute.

The maxAttempts argument defines the maximum number of allowed attempts, while decaySeconds specifies the number of seconds before the attempt counter is reset.

For example, the following Action allows 5 attempts within a 120-second period:

Rate Limit Response

When the Rate Limit is exceeded, the package automatically returns an HTTP 429 (Too Many Requests) response and prevents the Livewire Action from continuing its execution.

Using the LivewireRateLimiter Facade

The package also provides an alternative way to apply Rate Limiting to Livewire Actions using the LivewireRateLimiter Facade.

Call the handle method within the desired Livewire Action. The onAction argument accepts a Closure containing the logic that should be executed when the request is allowed.

Custom Limit Handling

The Facade-based approach allows you to define custom behavior when the Rate Limit is exceeded.

Pass a Closure to the handle method using the onLimit argument. This Closure is executed when the Rate Limit is exceeded.

This allows you to return a custom response or perform any additional process when the Rate Limit is exceeded.

Getting the Remaining Time

You may need to know how many seconds remain until the current Rate Limit expires. The getAvailableIn() method returns the remaining time in seconds.

Blade Directive

The package also provides a Blade conditional directive called @limitation.

It allows you to display custom content while the current Rate Limit is active.

If you find this package useful, please don't forget to give it a ⭐ on GitHub. ❤️

Testing

Run the test suite with:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy for information on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of livewire-rate-limiter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/support Version ^12.0||^13.0
livewire/livewire Version ^4.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 abolaradev/livewire-rate-limiter contains the following files

Loading the files please wait ...