Commit

765cd54

Protect your application with what your application knows A network firewall sees IPs, ports and request patterns. It doesn’t know that a login just failed, that an API key is on the free plan, or that /search is your most expensive endpoint. Your application knows all of that. So let it take part in its own defense. Phirewall https://github.com/flowd/phirewall is a PHP application firewall built as PSR-15 middleware. It runs inside your app, works with Laravel, Symfony, Slim, Mezzio and any other PSR-15 stack, and evaluates every request before it reaches your code. What it covers Rate limiting with fixed or sliding windows, Fail2Ban-style bans, hard volume caps, scanner and bot detection, trusted bot verification via reverse DNS, and IP/CIDR blocklists. SQL injection and XSS detection come through the OWASP CRS companion package. Counters live in APCu, Redis or any PDO database, so multi-server setups work out of the box. The interesting part: application insights Your login handler knows when authentication fails. Phirewall lets you report that directly:
$config->fail2ban->add('login-ban', threshold: 5, period: 300, ban: 3600,
    filter: fn($req) => false,
);

// in your login handler
$context = $request->getAttribute(RequestContext::ATTRIBUTE_NAME);
if (!$authenticated && $context instanceof RequestContext) {
    $context->recordFailure('login-ban');
}
Five failed logins in five minutes and the IP is banned for an hour. No log parsing, no guessing from the outside. The same idea works for throttles: limit by user, API key or plan instead of just by IP. One layer, not the whole wall Phirewall doesn’t replace your CDN, reverse proxy or network WAF. It adds the layer that only your application can provide. Combine it with the others and every layer covers what the previous one can’t see. PSR-14 events for every block, ban and throttle make it easy to feed Monolog, OpenTelemetry or your alerting. composer require flowd/phirewall Docs: https://phirewall.de
GitHubGitHub - flowd/phirewall: Phirewall is a PHP based application firewall that provides a PSR-15 middleware.Phirewall is a PHP based application firewall that provides a PSR-15 middleware. - flowd/phirewall

commit 765cd54