PHPackages                             kriosa/kriosa - 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. kriosa/kriosa

ActiveLibrary[Security](/categories/security)

kriosa/kriosa
=============

AI-Powered Web Application Middleware - Protect your apps from SQL injection, XSS, and 10+ attack vectors in 30 seconds

v1.0.0(1mo ago)00MITPHPPHP &gt;=7.4CI failing

Since Jun 20Pushed 1mo agoCompare

[ Source](https://github.com/Kriosa-ai/kriosa-php)[ Packagist](https://packagist.org/packages/kriosa/kriosa)[ Docs](https://kriosa.com)[ RSS](/packages/kriosa-kriosa/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Kriosa PHP SDK
==============

[](#kriosa-php-sdk)

[![PHP Version](https://camo.githubusercontent.com/b43c9d6cd8939c4868f963284928566c4c35dd2da0725c027f95a3d62f2f0329/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e342532422d626c75652e737667)](https://packagist.org/packages/kriosa-ai/kriosa-php)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Version](https://camo.githubusercontent.com/ba89a7edd5f97743be1ce64238bec511995f884cc2d4b0695ccb2c3b681121b2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d332e302e302d677265656e2e737667)](https://github.com/kriosa-ai/kriosa-php)

**Kriosa** is an intelligent security middleware for PHP applications that acts as a smart layer between users and your application, detecting, filtering, and logging malicious activities before they reach your core code.

AI-powered Web Application Middleware built for developers and businesses. One file. Zero dependencies. Instant protection.

---

📋 Table of Contents
-------------------

[](#-table-of-contents)

- [Features](#features)
- [How It Works](#how-it-works)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Framework Integrations](#framework-integrations)
- [Configuration](#configuration)
- [Production Recommendations](#production-recommendations)
- [What Developers Say](#what-developers-say)
- [Get Your API Key](#get-your-api-key)
- [Documentation](#documentation)
- [Support](#support)
- [License](#license)

---

✨ Features
----------

[](#-features)

- 🛡️ **AI-Powered Threat Detection** — Hybrid ML engine combining Random Forest and Neural Networks
- 🔍 **Comprehensive Attack Detection** — SQL Injection, XSS, Path Traversal, Command Injection, Bot Detection, Rate Limiting
- ⚡ **Local Fallback Protection** — Pattern matching runs locally when API is unavailable
- 🧠 **Explainable AI** — XAI dashboard shows exactly *why* a request was blocked with confidence scores
- 🌍 **Built for Africa** — Optimized for African web infrastructure and threat landscape
- 🚀 **Framework Agnostic** — Works with Laravel, WordPress, Symfony, and vanilla PHP
- ⚡ **High Performance** — Minimal overhead with ~5ms average response time
- 📊 **Real-time Analytics** — Live threat scoring, confidence levels, and attack metrics
- 🔒 **Zero Dependencies** — One file, drop-in protection

---

⚙️ How It Works
---------------

[](#️-how-it-works)

Kriosa uses a **multi-layer security architecture** to protect your application:

```
┌─────────────────────────────────────────────────────────────────┐
│                    Incoming Request                            │
└─────────────────────────┬───────────────────────────────────────┘
                          ▼
┌─────────────────────────────────────────────────────────────────┐
│              Layer 1: Local Pattern Matching                    │
│  • SQL Injection patterns                                      │
│  • XSS attack vectors                                          │
│  • Path traversal attempts                                     │
│  • Command injection                                           │
└─────────────────────────┬───────────────────────────────────────┘
                          ▼
                    [Matches?]
                    /        \
                   Yes        No
                    │          │
                    ▼          ▼
              ┌─────────┐  ┌─────────────────────────────────────┐
              │ BLOCKED │  │     Layer 2: AI Engine (API)       │
              └─────────┘  │  • Random Forest classification    │
                           │  • Neural Network analysis         │
                           │  • Confidence scoring              │
                           └──────────────┬──────────────────────┘
                                          ▼
                                   [API responds?]
                                   /             \
                                  Yes             No
                                   │               │
                                   ▼               ▼
                            ┌──────────┐   ┌─────────────────┐
                            │ AI       │   │ Layer 3:        │
                            │ Decision │   │ Fallback Logic  │
                            └──────────┘   └─────────────────┘
                                   │               │
                                   └───────┬───────┘
                                           ▼
                                   ┌───────────────┐
                                   │ ALLOW / BLOCK │
                                   └───────────────┘

```

**Key Benefit:** Even when the AI API is unavailable, the local pattern matching layer continues to block common attack vectors. Your application is never left completely unprotected.

---

📦 Installation
--------------

[](#-installation)

```
composer require kriosa-ai/kriosa-php
```

---

🚀 Quick Start
-------------

[](#-quick-start)

```
require 'vendor/autoload.php';

$kriosa = new Kriosa('sk_your_api_key');
$kriosa->protect();
```

### One-Line Protection

[](#one-line-protection)

```
kriosa_protect('sk_your_api_key');
```

---

🔧 Framework Integrations
------------------------

[](#-framework-integrations)

### Laravel Integration

[](#laravel-integration)

```
// In app/Http/Middleware/KriosaMiddleware.php
