Download the PHP package oltrematica/laravel-ratelimiter without Composer
On this page you can find all versions of the php package oltrematica/laravel-ratelimiter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oltrematica/laravel-ratelimiter
More information about oltrematica/laravel-ratelimiter
Files in oltrematica/laravel-ratelimiter
Package laravel-ratelimiter
Short Description a lightweight Laravel package that provides simple role management functionality.
License MIT
Informations about the package laravel-ratelimiter
Oltrematica API Rate Limiter
A Laravel package to manage rate limiters for APIs, used internally at Oltrematica for our projects.
Introduction
This package provides a simple configuration for rate limiters in APIs, allowing easy management of requests for login, registration, and general API routes. It is designed to be straightforward to integrate and configure within Laravel projects.
Installation
To install the package, run the following command in your terminal:
Configuration
The package includes a configuration file that can be customized. To publish the configuration file to your project, run the following command:
This will publish the rate-limiter.php
configuration file into your project's config
directory.
Usage
To apply rate limiters, use the following middleware in your routes:
- API Rate Limiter: Use the
throttle:api
middleware to apply rate limiting to API requests. - Login Rate Limiter: Use the
throttle:login
middleware to apply rate limiting to login requests. - Register Rate Limiter: Use the
throttle:register
middleware to apply rate limiting to registration requests.
Examples
Applying Rate Limiting to API Routes
In routes/api.php
:
Applying Rate Limiting to Login Route
In routes/web.php
:
Applying Rate Limiting to Registration Route
In routes/web.php
:
Configuration Options
The rate-limiter.php
configuration file allows you to customize request limits for each type of rate
limiter. You can override default values using environment variables in your .env
file.
Example .env
Variables
Code Quality
The project includes automated tests and tools for code quality control.
Rector
Rector is a tool for automating code refactoring and migrations. It can be run using the following command:
PhpStan
PhpStan is a tool for static analysis of PHP code. It can be run using the following command:
Pint
Pint is a tool for formatting PHP code. It can be run using the following command:
Automated Tests
The project includes automated tests and tools for code quality control.
Contributing
Feel free to contribute to this package by submitting issues or pull requests. We welcome any improvements or bug fixes you may have.