Download the PHP package cmatosbc/charon without Composer
On this page you can find all versions of the php package cmatosbc/charon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cmatosbc/charon
More information about cmatosbc/charon
Files in cmatosbc/charon
Package charon
Short Description Throttling in a simple and effective manner.
License gpl-3.0-or-later
Informations about the package charon
Charon
A simple yet powerful PSR-15 compliant rate limiting middleware for PHP applications. Charon provides an effective way to protect your applications from abuse through configurable request throttling.
Features
- 🚀 PSR-15 Middleware compliant
- 💾 PSR-16 Simple Cache support for storage
- 📝 Optional PSR-3 Logger integration
- ⚡ Efficient rate limiting using sliding window
- 🔒 IP and User-Agent based throttling
- 🎯 Configurable rate limits and time windows
- 📊 Standard rate limit headers (X-RateLimit-*)
- 🚫 Automatic blacklisting for repeat offenders
Installation
You can install the package via composer:
Usage
Basic Usage
With Logging
With Automatic Blacklisting
When blacklisting is enabled:
- Clients exceeding rate limits multiple times will be tracked
- After reaching the specified number of violations, the client will be blacklisted
- Blacklisted clients receive a 403 Forbidden response
- Violations are tracked across multiple time windows
- Blacklist status is stored in cache with client signature
Framework Integration Examples
Slim 4
Laravel
Symfony
WordPress REST API
Response Headers
The middleware adds standard rate limit headers to responses:
When the rate limit is exceeded, a 429 (Too Many Requests) response is returned with:
When a blacklisted client attempts to access the resource:
Logging
When logging is enabled, the middleware logs the following information:
Rate Limit Exceeded (Warning Level)
Client Blacklisted (Alert Level)
Request Processed (Info Level, when logAllRequests is true)
Use Cases
- API Rate Limiting: Protect your API from abuse by limiting requests per client
- Login Throttling: Prevent brute force attacks by limiting login attempts
- Resource Protection: Protect expensive operations from overuse
- DDoS Mitigation: Basic protection against distributed denial of service attacks
- Fair Usage: Ensure fair resource distribution among clients
- Abuse Prevention: Automatically block repeat offenders with blacklisting
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The GNU General Public License v3.0. Please see License File for more information.
All versions of charon with dependencies
psr/cache Version ^3.0
psr/http-message Version ^2.0
nyholm/psr7 Version ^1.8
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/log Version ^3.0