Download the PHP package gnikolovski/cb-rate-limiter without Composer

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

CB Rate Limiter

Couchbase API Rate Limiter is a super simple PHP package for limiting access to your public API. It was originally created for one of my projects, and I'm using it with Slimframework, but it could be used in any of your projects.

I decided to go with Couchbase, because the rest of my application was using this database to store data. Couchbase is a super fast NoSQL database, so it is perfect for this kind of tasks.

How to install?

The easiest and recommended method to install CB Rate Limiter is via composer:

How to use it?

Best way to use this package is as a middleware on your routes. Put it first - before any other middleware, and if user has reached the limit you imposed, you should return http code 429 (too many requests) with appropriate headers.

This is how you could use this package with Slimframework as a middleware:

Class is instantiated with the following three variables in the constructor:

$hostname - IP address of your Couchbase server

$bucket - name of the bucket where you will store data

$password - database password

After you create $limiter object you have to call isExceeded() method and provide the following data:

$ip_address - IP address of user trying to access API route

$max_requests - max requests you are willing to accept in a unit of time

$in_minutes - unit of time

IP address of the user could be supplied using global PHP variable:

or by using some package, like akrabat/rka-ip-address-middleware.

Variables $max_requests and $in_minutes should be integers. If you want to accept 100 requests from one IP address in 60 minutes you would write:

Requirements

To use Couchbase in PHP you must install PHP SDK. To find out more visit: (http://developer.couchbase.com/documentation/server/4.0/sdks/php-2.0/download-links.html)

AUTHOR

Goran Nikolovski - https://gorannikolovski.com


All versions of cb-rate-limiter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.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 gnikolovski/cb-rate-limiter contains the following files

Loading the files please wait ....