PHPackages                             aayushgauba/aiwaf - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. aayushgauba/aiwaf

ActiveLibrary[Security](/categories/security)

aayushgauba/aiwaf
=================

Adaptive Intelligent Web Application Firewall for PHP

04PHPCI failing

Since Jun 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/aiwaf-project/aiwaf-php)[ Packagist](https://packagist.org/packages/aayushgauba/aiwaf)[ RSS](/packages/aayushgauba-aiwaf/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

AIWAF PHP
=========

[](#aiwaf-php)

Adaptive, trainable web-application firewall middleware for PHP applications.

This README is an end-to-end guide: install, integrate, train, tune, validate, and operate.

What You Get
------------

[](#what-you-get)

- **AST-based Route Discovery**: Parses PHP, Laravel, and Symfony routes without booting the framework.
- **Framework Plug-and-Play**: Native bindings for Laravel and Symfony.
- **Header profile validation**
- **IP blocking and allowlisting helpers**
- **Rate limiting** with pluggable backends (In-memory, APCu, Redis, DB)
- **Dynamic keyword detection**
- **UUID tamper checks**
- **Method Validation &amp; Honeypots**: Instantly blocks scanner bots firing GET requests at POST-only endpoints.
- **Standardized Block Responses**: JSON-formatted 403 and 429 payloads.
- **Isolation Forest anomaly scoring**
- **CLI Management Tool** for training, WHOIS lookups, and block management.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Composer
- Optional: ext-redis when using Redis adapters/drivers

CLI Management Tool
-------------------

[](#cli-management-tool)

AIWAF-PHP ships with a standalone executable: `bin/aiwaf`. You can run:

- `php bin/aiwaf train`: Train anomaly models from logs.
- `php bin/aiwaf whois `: View WHOIS / Geo details for an IP.
- `php bin/aiwaf block `: Add an IP to the global blacklist.
- `php bin/aiwaf unblock `: Remove an IP from the blacklist.

Package Configuration (Composer)
--------------------------------

[](#package-configuration-composer)

`composer.json` package-level defaults and scripts:

- Name: `aayushgauba/aiwaf`
- Type: `library`
- License: `MIT`
- Runtime dependency: `php >= 7.4`
- Suggested extension: `ext-redis` (only required for Redis adapter/driver)
- PSR-4 autoload: `AIWAF\\` -&gt; `src/`
- Dev autoload: `AIWAF\\Tests\\` -&gt; `tests/`
- Composer scripts:
    - `composer test`
    - `composer run cover-everything`
    - `composer run test-adapters-matrix`
    - `composer run validate-all`

Install
-------

[](#install)

```
composer require aayushgauba/aiwaf
```

End-to-End Setup
----------------

[](#end-to-end-setup)

### 1. Initialize resources

[](#1-initialize-resources)

```
php setup.php
```

Runtime artifacts are stored under `resources/` by default:

- `blocked_ips.json`
- `dynamic_keywords.json`
- `request_features.csv`
- `forest_model.json`

### 2. Add protection to your bootstrap/front controller

[](#2-add-protection-to-your-bootstrapfront-controller)

Run AIWAF before output is sent.

```
