skydiver/laravel-route-blocker
Block routes in Laravel with a simple, configurable middleware layer. Restrict access by IP, environment, or custom rules, and return clean 403 responses. Lightweight and easy to drop into any Laravel app.
Architecture fit. skydiver/laravel-route-blocker is a single-purpose Laravel middleware package that rejects requests from configured IP addresses before they reach controllers. Architecturally it slots into the HTTP kernel's middleware stack — either globally or scoped to route groups — and relies on a published config file for its blocklist. That is the right shape for a defensive control in a Laravel app: no service container gymnastics, no database dependency, no queue or event footprint. It overlaps with what a WAF, load balancer ACL, or throttle middleware already does, so the TPM question is whether it earns a slot as an application-layer backstop or is redundant with existing edge controls.
Integration feasibility. Low effort. Standard composer install, config publish, and middleware registration. The main integration work is not the package itself but establishing a trustworthy client-IP resolution path (trusted proxies / TrustProxies) so the middleware sees the real client address rather than the load balancer's. Expect a half-day of engineering plus staging validation for a typical app.
Technical risk.
TrustProxies is misconfigured, the middleware either blocks everyone (sees the proxy IP) or blocks no one (attacker-supplied X-Forwarded-For).Key questions for the maintainer / spike.
TrustProxies, or does it read $request->ip() naively?Stack fit. Any Laravel application on a supported version. It sits cleanly alongside existing middleware (auth, throttle, VerifyCsrfToken) and does not interfere with routing, Eloquent, or the container. It is a natural fit for apps that already treat configuration as code and deploy frequently; it is a poor fit for apps needing runtime blocklist edits by support staff.
Migration path.
composer.json ("skydiver/laravel-route-blocker": "x.y.z") rather than a floating constraint.Compatibility. Confirm the package's composer.json constraints against the app's Laravel and PHP versions before committing; run the full test suite and a smoke test of the auth and public routes with the middleware enabled. If the app is on Laravel 11+ with the slimmed bootstrap/app.php middleware registration, verify the registration style still applies.
Sequencing. Package evaluation spike (1 day) → proxy/IP-resolution fix if needed → staging rollout on one route group → production canary → global rollout → document in the runbook. Keep the edge WAF/LB ACL as the primary control and treat this as defense-in-depth; do not decommission existing controls on the strength of this package.
Maintenance. Very low ongoing effort but non-zero: config-only blocklist means changes ride the normal deploy pipeline, and config:cache must be cleared as part of any blocklist update. Dependency surface is one small package, so upgrade friction is minimal until a Laravel major lands — at which point expect to wait or patch.
Support. Community-supported with a small maintainer base. Pin the version, mirror the repo internally or keep a fork ready, and assign a named owner. Do not place it on a critical path where a broken release during a Laravel upgrade would block the upgrade itself.
Scaling. Per-request cost is negligible — an in-memory array comparison against the resolved IP. It scales horizontally with the app since it is stateless. The scaling limitation is operational, not computational: a blocklist that must be accurate across N instances and updated within minutes is not a good fit for config-file distribution.
Failure modes.
Ramp-up. Low. An engineer familiar with Laravel middleware can integrate and document it in under a day; the real time investment is the proxy/IP-resolution audit, which is required regardless of this package and is the part most likely to surface pre-existing bugs in the app's TrustProxies configuration. Net TPM recommendation: adopt as a cheap, low-risk secondary control with a pinned version and an explicit owner; do not position it as the primary abuse-prevention mechanism.
How can I help you explore Laravel packages today?