Download the PHP package kode/limiting without Composer

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

kode/limiting

高性能 PHP 限流器,支持令牌桶、漏桶、滑动窗口、滑动窗口计数器、固定窗口计数器与多规则组合限流;内置内存 / APCu / Redis / Memcached / PDO 存储与分布式并发控制。PHP 8.3+。

功能特性

系统要求

安装

统一入口 Limiter(推荐)

Limiter 实例方法:allow() / check()(返回 LimiterResult)/ consume() / consumeOrFail()(超限抛 RateLimitExceededException)/ getRemaining() / getWaitTime() / reset() / getCapacity();流式配置 withCapacity() / withRate() / withTtl() / withPrefix() / withStore() / withType() / withEventHandler()(均返回新实例,保持不可变)。

快速开始

本地限流(令牌桶)

组合限流

并发控制(共享槽位信号量)

v2.0 迁移提示:v1.x 的 TaskLimiter::create($max, $capacity, $rate)、ProcessLimiter::getInstance($max, $capacity, $rate)、new FiberLimiter($max, $capacity, $rate, $store) 已全部改为「共享槽位信号量」语义。并发上限现在真实生效,旧签名不再兼容。

分布式限流(跨机器)

声明式注解

配置驱动注册表 LimiterManager

用一份数组在框架引导阶段集中声明多条限流规则,运行期按业务名取用:

同名存储只构建一次并复用;store 字段可填存储名、存储配置数组或类型字符串。

容灾降级与事件回调

把任意存储包进 ResilientStore,底层(Redis / PDO 等)不可用时按策略兜底,业务不会被限流器拖垮:

降级结果会体现在 LimiterResult(额外携带 degraded / degradedReason)与响应头(X-RateLimit-Degraded: 1)上,便于观测。

事件回调(LimiterEventHandler)则在每次决策后 / 异常时触发,方便接入日志、指标与告警:

LimiterMiddleware 同样支持 withEventHandler(),并在降级时把 X-RateLimit-Degraded 写入响应头。

架构

API 速查

StoreInterface

RateLimiterInterface

LimiterResult

LimiterConfig

单元测试

测试覆盖全部核心功能,共 125 个测试用例、540 项断言(PHPUnit 10.5/11,PHP 8.3),全绿。

自定义存储

实现 StoreInterface 即可:

开发

从 v1.x 升级到 v2.0

从 v2.0 升级到 v2.1

v2.1.0 为向后兼容的增量版本(纯新增能力,未改动既有 API 行为):

既有调用方式(v2.0)无需任何改动即可升级到 v2.1.0。

从 v2.1 升级到 v2.2

v2.2.0 为向后兼容的增量版本(新增可选参数,未改动既有 API 行为):

既有调用方式(v2.1)无需任何改动即可升级到 v2.2.0——所有新参数均带默认值 'kode:limiting:'。

许可证

Apache License 2.0 - 参见 LICENSE 文件


All versions of limiting with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
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 kode/limiting contains the following files

Loading the files please wait ...