Download the PHP package harmlessprince/superban without Composer

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

Superban Package

SuperBan is a Laravel middleware package that helps you manage and control the rate of incoming requests to your application. It can be useful in scenarios where you want to prevent abuse, limit the number of requests from a specific route or group of route the client and enforce temporary bans when necessary.

The package is designed using the Token Bucket Algorithm. Below is a brief explanation of the algorithm from Google `The token bucket is an algorithm used in packet-switched and telecommunications networks. It can be used to check that data transmissions, in the form of packets, conform to defined limits on bandwidth and burstiness (a measure of the unevenness or variations in the traffic flow). ` In the concept of this Superban package, below is a brief explanation of how it works. The middleware has a first parameter called maximumRequest. This maximum request parameter represents our tokens and is associated with a key in the cache. So each incoming request into our server consumes a token; if no tokens are left, the request is rejected. If the client tries to hit the same endpoint again within the interval specified for the token to be used, the client is then banned from the specific route for the duration of the ban time supplied. `Note: All supplied parameters are expected to be in minutes.`

Installation

Once the Superban package is installed, the package will be autoloaded, this package is built with php 8.1. Any Laravel version that supports PHP 8.1 will autoload the package; however, if you want to add it yourself.

Open up config/app.php and add the following to the providers key.

Configuration

The default cache driver is file; you can change it to any laravel supported cache driver in your environment variable like below

You can publish the configuration file using this command:

A configuration-file named superban.php with defaults will be placed in your config directory:

Usage

To use the SuperBan middleware in your routes, you can apply it like any other middleware. For example, in your routes file or controller: You can customize the SuperBan behaviour by providing additional parameters:

Exceptions

Extra

When you use the middlware in your route, the package adds some headers to every response going out of the application like below

The response header below implies the client has excided the maximum number of requests and can try again in 18 seconds.

Testing

Test Result Should Look Like This

Author

Name: Adewuyi Taofeeq
Email: [email protected]
LinkenIn: Adewuyi Taofeeq Olamikean

License

MIT


All versions of superban with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 harmlessprince/superban contains the following files

Loading the files please wait ....