Download the PHP package wafio/wafio-client-php without Composer
On this page you can find all versions of the php package wafio/wafio-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wafio/wafio-client-php
More information about wafio/wafio-client-php
Files in wafio/wafio-client-php
Package wafio-client-php
Short Description PHP client for Wafio WAF TCP mTLS (analyze requests, check block). Feature parity with Node.js and Go clients.
License MIT
Homepage https://github.com/Wafio/wafio-client-php
Informations about the package wafio-client-php
wafio-client-php
A production-ready PHP client for Wafio WAF over TCP mTLS. Analyze incoming HTTP requests and check whether a client key is currently blocked.
Works with:
- ✅ PHP 8.1+
- ✅ Laravel, Symfony, and plain PHP
- ✅ Full type hints and PHPDoc
Features:
- Fail-open by default (circuit breaker behavior)
- FPM-safe connection model (connect per operation, then close)
- mTLS authentication with server verification
- Framework-agnostic helpers for request-to-analyze conversion
- Feature parity with TypeScript and Go clients (
analyze,checkBlock,getTierLimits)
Installation
Monorepo local path example:
Then run:
Quick Start
1. Prepare mTLS credentials
Generate or download your project mTLS key from the Wafio dashboard and save it as JSON (for example mtls-credentials.json).
Expected fields:
2. Create a client and analyze a request
Laravel shortcut (no manual body/header mapping in middleware):
The client automatically handles:
- request header normalization
- real client IP resolution
- multipart preview body +
body_size - large body fallback to
body_b64
3. Check block window
Core Concepts
analyze() vs checkBlock()
analyze()performs full WAF inspection and returns decision metadata (action,score,categories,message).checkBlock()is a fast block-window lookup for a key (for example IP or user key).
Fail-open behavior
By default, if Wafio is unavailable:
- Request is allowed.
- Failure counter increments.
- After threshold is reached, cooldown is applied.
- During cooldown, requests are immediately allowed (no network attempt).
This prevents your app from hard-failing when Wafio is temporarily down.
PHP-FPM connection model
This client is intentionally optimized for PHP-FPM:
- Opens connection per operation (
analyze,checkBlock,getTierLimits) - Closes connection after response
- Avoids stale shared sockets across independent requests
Request Helpers
Use Helpers to build analyze payloads consistently across frameworks.
Client IP resolution order:
X-Forwarded-For(first IP)X-Real-IPForwardedremoteAddress
Configuration
Required option:
credentials: file path or PEM array containingclient_cert_pem,client_key_pem,ca_pem(optionaltcp_url)
Optional options:
host(optional override; default fromtcp_urlif available, elselocalhost)port(optional override; default fromtcp_urlif available, else9089)
Built-in behavior values:
| Setting | Value |
|---|---|
| request timeout | 2000ms |
| connect timeout | 2000ms |
| failure threshold | 3 |
| cooldown | 60s |
API Surface
Main class: Wafio\Client\WafioClient
connect(): voidanalyze(array $req): arrayanalyzeFromLaravelRequest($request, array $overrides = []): arraycheckBlock(string $key): arraygetTierLimits(): ?intclose(): void
Helpers:
Wafio\Client\Helpers::buildAnalyzeRequest(array $snapshot): arrayWafio\Client\Helpers::resolveClientIp(?array $headers, ?string $remoteAddress = null): stringWafio\Client\Credentials::loadFromFile(string $filePath): array
Examples
packages/wafio-client-php/examples/laravel-samplepackages/wafio-client-php/examples/laravel-sample-altpackages/wafio-client-php/examples/form-example.php
Troubleshooting
credentials must include ca_pem→ ensure JSON includesca_pem- TLS/connect errors → check host/port and server certificates
- Requests always allowed when server is down → expected fail-open behavior
License
MIT
All versions of wafio-client-php with dependencies
ext-json Version *
ext-openssl Version *