7 Commits

Author SHA1 Message Date
Jean-Marc Strauven
c72b740749 Merge pull request #21 from Grazulex/docs/suggest-optional-packages
docs: add idempotency and throttle-smart as suggested packages
2026-02-05 05:32:52 +01:00
Jean-Marc Strauven
2791415401 docs: add laravel-api-idempotency and laravel-api-throttle-smart as suggested packages
- Add both packages to composer.json suggest section
- Document usage, installation and attention points in README
- Add to Features list and Credits section
2026-02-05 05:32:14 +01:00
Jean-Marc Strauven
ada996848a Merge pull request #20 from Grazulex/chore/update-dependencies
chore(deps): update Composer dependencies
2026-02-02 09:49:43 +01:00
Jean-Marc Strauven
43a36e4913 chore(deps): update Composer dependencies
Update all dependencies to their latest PHP 8.3 compatible versions:
- laravel/framework v12.46.0 → v12.49.0
- laravel/sanctum v4.2.2 → v4.3.0
- grazulex/laravel-apiroute v2.0.3 → v2.0.5
- spatie/laravel-data 4.18.0 → 4.19.1
- spatie/laravel-query-builder 6.3.6 → 6.4.1
- phpstan/phpstan 2.1.35 → 2.1.38
- pestphp/pest v4.3.1 → v4.3.2
- rector/rector 2.3.2 → 2.3.5

Added platform PHP 8.3 constraint to prevent Symfony 8.x packages
from being installed (requires PHP 8.4).
2026-02-02 09:48:37 +01:00
Jean-Marc Strauven
8b0b57808b Merge pull request #19 from Grazulex/Grazulex-patch-1
Update funding information in FUNDING.yml
2026-02-02 05:22:31 +01:00
Jean-Marc Strauven
5cad524908 Update funding information in FUNDING.yml 2026-02-02 05:22:17 +01:00
Jean-Marc Strauven
84a094666d Merge pull request #18 from Grazulex/release/v2.2.0
chore(release): 2.2.0
2026-01-29 04:21:56 +01:00
4 changed files with 339 additions and 245 deletions

4
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,4 @@
# These are supported funding model platforms
github: Grazulex
buy_me_a_coffee: Grazulex
custom: ["https://paypal.me/strauven"]

View File

@@ -21,6 +21,8 @@ A production-ready, API-only Laravel 12 starter kit following the 2024-2025 REST
- **Rate Limiting** - Configurable per-route rate limiters
- **Reusable Middleware** - ForceJsonResponse, LogApiRequests, EnsureEmailVerified
- **Standardized Responses** - Consistent JSON response format
- **Optional: API Idempotency** - RFC-compliant idempotency via [grazulex/laravel-api-idempotency](https://github.com/Grazulex/laravel-api-idempotency)
- **Optional: Smart Rate Limiting** - Plan-aware throttling with quotas via [grazulex/laravel-api-throttle-smart](https://github.com/Grazulex/laravel-api-throttle-smart)
## Requirements
@@ -465,6 +467,83 @@ X-RateLimit-Remaining: 59
Retry-After: 60 # When limit exceeded
```
## Optional Packages
The following packages are **suggested** (not required) and can be installed individually to extend the kit's capabilities. They are fully opt-in and will not affect existing behavior.
### API Idempotency
[grazulex/laravel-api-idempotency](https://github.com/Grazulex/laravel-api-idempotency) provides RFC-compliant idempotency for your API endpoints. It prevents duplicate operations when clients retry requests (critical for payments, order creation, etc.).
**Install:**
```bash
composer require grazulex/laravel-api-idempotency
```
**Publish config (optional):**
```bash
php artisan vendor:publish --tag="api-idempotency-config"
```
**Usage — apply the middleware to mutation routes:**
```php
// routes/api/v1.php
Route::middleware(['auth:sanctum', 'throttle:authenticated'])->group(function () {
Route::post('orders', [OrderController::class, 'store'])
->middleware('idempotent');
Route::post('payments', [PaymentController::class, 'store'])
->middleware('idempotent:required'); // Require Idempotency-Key header
});
```
**Client-side — include the `Idempotency-Key` header:**
```bash
curl -X POST http://localhost:8080/api/v1/orders \
-H "Authorization: Bearer 1|abc123..." \
-H "Idempotency-Key: order_unique_key_123" \
-H "Content-Type: application/json" \
-d '{"product_id": 1, "quantity": 2}'
```
> **Attention:**
> - Only apply the `idempotent` middleware to mutation routes (POST, PUT, PATCH). GET requests are naturally idempotent.
> - The default storage driver is `cache`. For production with multiple servers, use the `redis` or `database` driver.
> - Keys are scoped per user by default. Two different users can use the same key without conflict.
---
### Smart Rate Limiting
[grazulex/laravel-api-throttle-smart](https://github.com/Grazulex/laravel-api-throttle-smart) provides plan-aware rate limiting with quotas, multiple algorithms (fixed window, sliding window, token bucket), and multi-tenant support. Ideal for SaaS APIs with subscription tiers.
**Install:**
```bash
composer require grazulex/laravel-api-throttle-smart
```
**Publish config:**
```bash
php artisan vendor:publish --tag="throttle-smart-config"
```
**Usage — apply to routes where plan-based limiting is needed:**
```php
// routes/api/v1.php
Route::middleware(['auth:sanctum', 'throttle.smart'])->group(function () {
Route::apiResource('posts', PostController::class);
});
```
> **Attention:**
> - This package **coexists** with Laravel's built-in `throttle:` middleware. You do not need to remove the existing rate limiters.
> - If you want to **replace** the native throttle on specific routes, swap `throttle:authenticated` with `throttle.smart` on those routes only.
> - Do **not** apply both `throttle:authenticated` and `throttle.smart` on the same route group — choose one per group to avoid double rate limiting.
> - The default driver is `cache`. For production, `redis` is recommended for performance and distributed consistency.
> - Configure your subscription plans in `config/throttle-smart.php` to match your business model (Free, Pro, Enterprise, etc.).
---
## Middleware
The kit includes three production-ready middleware patterns that you can apply to your routes as needed.
@@ -814,6 +893,8 @@ This project is open-sourced software licensed under the [MIT license](LICENSE).
- [spatie/laravel-query-builder](https://github.com/spatie/laravel-query-builder) - Query Building
- [spatie/laravel-data](https://github.com/spatie/laravel-data) - Data Transfer Objects
- [dedoc/scramble](https://github.com/dedoc/scramble) - API Documentation
- [grazulex/laravel-api-idempotency](https://github.com/Grazulex/laravel-api-idempotency) - API Idempotency (optional)
- [grazulex/laravel-api-throttle-smart](https://github.com/Grazulex/laravel-api-throttle-smart) - Smart Rate Limiting (optional)
- [Pest PHP](https://pestphp.com) - Testing Framework
## Support

View File

@@ -27,6 +27,10 @@
"pestphp/pest-plugin-laravel": "^4.0",
"rector/rector": "^2.2"
},
"suggest": {
"grazulex/laravel-api-idempotency": "RFC-compliant API idempotency with response caching and multiple storage drivers",
"grazulex/laravel-api-throttle-smart": "Plan-aware smart rate limiting with quotas, multiple algorithms and multi-tenant support"
},
"autoload": {
"psr-4": {
"App\\": "app/",
@@ -88,6 +92,9 @@
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
},
"platform": {
"php": "8.3.30"
}
},
"minimum-stability": "stable",

492
composer.lock generated

File diff suppressed because it is too large Load Diff