Skip to content

A simple PHP Rate Limiting Script that allows developers to limit incoming requests.

License

Notifications You must be signed in to change notification settings

LCGF00/RateLimit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

PHP Rate Limiting Client

A simple PHP Rate Limiting Script that allows developers to limit incoming requests.

Install

Download:

Chose the version you want and download the files from that folder. Upload all these files to your website and then you'll be ready to go.

Usage

First, lets import the main file:

require_once 'ratelimit/main.php';

This file acts as an autoloader and will automatically import the needed files.


Create an Allias of the Main Class & Construct a new RateLimiter Class:

use RateLimit\RateLimiter;
$limit = new RateLimiter( 10 );

This creates a new RateLimiter class that specifies all clients have a maximum of 10 requests per given minute.


Initate the script to fetch the amount of requests for the given Client:

$response = $limit->limitClient(); 

Detect whether the client has exceeded the maximum amount of requests:

if ($response->clientExceededMaxRequests()) {
	http_response_code(429);
}

This will set the HTTP Response Code to 429 (Too Many Requests) if the Client has exceeded the maximum amount of requests.


Copyright Mumbo Jumbo

Lets keep it short, view the license at https://tbmproduction.com/license

About

A simple PHP Rate Limiting Script that allows developers to limit incoming requests.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages