composer require php-next/webshield-open
This will install WebShield Open-Core and all dependencies.
Create a config file at config/webshield.config.php:
return [
'mode' => 'protect', // observe | protect | deceive | aggressive
'sensitivity' => 3, // 1-5
'log_level' => 'info', // info | debug | forensic
'honeypots' => ['login', 'db', 'api'],
'allowed_ips' => [],
'blocked_ips' => [],
'log_path' => __DIR__ . '/logs/webshield.log',
];
Logs are written as JSON lines, one event per line:
{"ts":"2025-11-30T18:00:00Z","ip":"1.2.3.4","url":"/wp-admin","level":"high","mode":"protect","rules":["scanner_paths"],"plan":"block"}
This format is compatible with log aggregators like ELK, Splunk, and Grafana.
Tracks multiple failed login attempts from the same IP within a time window (default: 10 attempts in 5 minutes).
Threat levels are calculated based on score thresholds:
Thresholds are configurable in webshield.config.php.
Use WebShieldFactory for easy setup:
use PhpNext\WebShieldOpen\WebShield\WebShieldFactory;
$shield = WebShieldFactory::fromDefaults();
$response = $shield->handle($_SERVER, $_GET, $_POST, getallheaders());
if ($response !== null) {
http_response_code($response['status']);
foreach ($response['headers'] as $k => $v) {
header("$k: $v");
}
echo $response['body'];
exit;
}
Or try the demo site included in the package.