Download the PHP package mehr-it/lara-token-bucket without Composer

On this page you can find all versions of the php package mehr-it/lara-token-bucket. 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 lara-token-bucket

Token bucket algorithm for laravel

Implements the "Token bucket" algorithm using laravel's cache repositories.

Note: This implementation uses a clock resolution of one second. This means, new tokens are added every second at most.

Install

composer require mehr-it/lara-token-bucket

This package uses Laravel's package auto-discovery, so the service provider will be loaded automatically.

Usage

Use the TokenBucket facade to access a token bucket:

All token bucket instances with the same name use the same token store, as long as the use the same underlying cache.

Estimate time until tokens are available

Sometimes, it might be helpful to estimate the duration until new tokens become available. The tryTake() method returns the estimated time to the second parameter if given. If you just want to check the estimated availability without taking tokens out, the estimateAvailability() method is what you are looking for.

Putting tokens back

Sometimes, you might have taken a token which you didn't need. You can give tokens back to buckets without affecting the time-based filling:

Predefined buckets

If you want to predefine token buckets and use them later by resolving the bucket name, the registerBucket() method is what you need:

Edge cases

By default, buckets are empty when no data exists. This happens the first time a bucket is requested or after a cache flush.

You may define the initial number of tokens a bucket holds, when creating a bucket instance:


All versions of lara-token-bucket with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
laravel/framework Version ^5.8|^6.0|^7.0|^8.0|^9.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 mehr-it/lara-token-bucket contains the following files

Loading the files please wait ....