Download the PHP package nabilhassen/laravel-usage-limiter without Composer

On this page you can find all versions of the php package nabilhassen/laravel-usage-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 laravel-usage-limiter

Laravel Usage Limiter

Tests

Introduction

A Laravel package to track, limit & restrict usages by setting them on your models (usually User model).

Features

Use cases

Basically with this package you can track your users' or any other models' usages and restrict them when they hit their maximum limits.

Example use-cases:

Versions

Compatible for Laravel versions >= 8.0.

Installation

Install Laravel Usage Limiter using the Composer package manager:

Next, you should publish the Laravel Usage Limiter configuration and migration files using the vendor:publish Artisan command:

Finally, you should run the migrate command in order to create the tables needed to store Laravel Usage Limiter's data:

Basic Usage

First, you need to use the HasLimits trait on your model.

Create your Limits

Possible values for "reset_frequency" column

Set Limits on models

Set Limits on models with beginning used amounts

If a user has already consumed limits then:

Unset Limits from models

Consume/Unconsume Limits

Reset Limits for models

All available methods

Method Return Type Parameters
setLimit bool string|Limit $limit,
?string $plan = null,
float|int $usedAmount = 0.0
unsetLimit bool string|Limit $limit,
?string $plan = null
isLimitSet bool string|Limit $limit,
?string $plan = null
useLimit bool string|Limit $limit,
?string $plan = null,
float|int $amount = 1.0
unuseLimit bool string|Limit $limit,
?string $plan = null,
float|int $amount = 1.0
resetLimit bool string|Limit $limit,
?string $plan = null
hasEnoughLimit bool string|Limit $limit,
?string $plan = null
usedLimit float string|Limit $limit,
?string $plan = null
remainingLimit float string|Limit $limit,
?string $plan = null
limitUsageReport array string|Limit|null $limit = null,
?string $plan = null

All available commands

Command Arguments Example
limit:create name: required
allowed_amount: required
plan: optional
php artisan limit:create --name products --allowed_amount 20 --plan premium
limit:delete name: required
plan: optional
php artisan limit:delete --name products --plan premium
limit:list None php artisan limit:list
limit:reset None php artisan limit:reset # reset limit usages to 0
limit:cache-reset None php artisan limit:cache-reset # flushes limits cache

Blade

Schedule Limit Usage Resetting

The limit:reset command will reset your model's (e.g. user) limit usages based on the Limit's reset_frequency.

Add limit:reset command to the console kernel.

Advanced Usage

Extending

Clear your config cache if you have made any changes in the limit.php config file.

Caching

By default, Laravel Usage Limiter uses the default cache you chose for your app. If you would like to use any other cache store you will need to change the store key in the limit.php config file to your preferred cache store.

Manual Cache Reset

In your code

Via command line

Testing

Security

If you have found any security issues, please send an email to the author at [email protected].

Contributing

You are welcome to contribute to the package and you will be credited. Just make sure your PR does one thing and add tests.

License

The Laravel Usage Limiter is open-sourced software licensed under the MIT license MIT license.


All versions of laravel-usage-limiter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/database Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/console Version ^8.0|^9.0|^10.0|^11.0
nesbot/carbon Version ^2.67|^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 nabilhassen/laravel-usage-limiter contains the following files

Loading the files please wait ....