cresjie/ip-blocker
Simple Laravel 5 IP blocker. Install via Composer, publish config, and list blocked IPs in config/cresjie/block-ip.php. When a request matches, it throws IpBlockerException so you can render a custom “blocked” view in your exception handler.
ip_blocker). Assumes standard Laravel database setup; no support for external storage (Redis, etc.).$middleware array) or route-specific middleware. Example:
Route::middleware(['ip.blocker'])->group(function () {
// Protected routes
});
composer.json adjustments for newer PHP features.CREATE TABLE ip_blocker (
ip_address VARCHAR(45) PRIMARY KEY,
created_at TIMESTAMP
);
composer require cresjie/ip-blocker
config/app.php (if not auto-discovered).php artisan vendor:publish --provider="Cresjie\IpBlocker\IpBlockerServiceProvider"
php artisan migrate
app/Http/Kernel.php.// In IpBlockerMiddleware.php
public function handle($request, Closure $next) {
// Updated for Laravel 8+ DI
$blockedIps = app(\Cresjie\IpBlocker\Repositories\IpBlockerRepository::class)->getBlockedIps();
// ...
}
Log::info).ip_blocker table. For high traffic, consider:
Redis::sismember('blocked_ips', $ip)).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database downtime | All IP blocking fails silently. | Fallback to manual firewall rules (e.g., AWS WAF). |
| Package incompatibility | Middleware fails to load. | Feature flag or custom middleware. |
| IP list corruption | False positives/negatives. | Regular backups of ip_blocker table. |
| High traffic | Database overload. | Cache blocked IPs; optimize queries. |
| Laravel upgrade | Package breaks. | Test in staging; isolate in a container. |
How can I help you explore Laravel packages today?