PHPackages                             m9nx/laravel-runtime-guard - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. m9nx/laravel-runtime-guard

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

m9nx/laravel-runtime-guard
==========================

A security-focused runtime monitoring and guard layer for Laravel applications

1.0.0(4mo ago)10MITPHPPHP ^8.1

Since Jan 6Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/M9nx/laravel-runtime-guard)[ Packagist](https://packagist.org/packages/m9nx/laravel-runtime-guard)[ Docs](https://github.com/m9nx/laravel-runtime-guard)[ RSS](/packages/m9nx-laravel-runtime-guard/feed)WikiDiscussions main Synced 1mo ago

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

Laravel RuntimeGuard
====================

[](#laravel-runtimeguard)

[![Packagist](https://camo.githubusercontent.com/2d40e2a83b62f1e7e12626f8b5aaf44a78998abf1f97c2244b14cde35e6b4c90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d396e782f6c61726176656c2d72756e74696d652d6775617264)](https://camo.githubusercontent.com/2d40e2a83b62f1e7e12626f8b5aaf44a78998abf1f97c2244b14cde35e6b4c90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d396e782f6c61726176656c2d72756e74696d652d6775617264)[![Downloads](https://camo.githubusercontent.com/21b402bc61357fec4703a2568be0d3e1a725a074492cd9646977f354fdfc1d88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d396e782f6c61726176656c2d72756e74696d652d6775617264)](https://camo.githubusercontent.com/21b402bc61357fec4703a2568be0d3e1a725a074492cd9646977f354fdfc1d88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d396e782f6c61726176656c2d72756e74696d652d6775617264)[![License](https://camo.githubusercontent.com/c0b51974a274b1430238e3d63f787488b6c7cb4af6dd9cad9d6f57027328fe73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d396e782f6c61726176656c2d72756e74696d652d6775617264)](https://camo.githubusercontent.com/c0b51974a274b1430238e3d63f787488b6c7cb4af6dd9cad9d6f57027328fe73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d396e782f6c61726176656c2d72756e74696d652d6775617264)

**Enterprise-grade runtime security inspection for Laravel applications.**

RuntimeGuard provides a comprehensive, extensible framework for runtime security monitoring. Unlike static analyzers, it inspects actual data flowing through your application in real-time, detecting threats before they can cause damage.

---

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

[](#table-of-contents)

- [Laravel RuntimeGuard](#laravel-runtimeguard)
    - [Table of Contents](#table-of-contents)
    - [Features](#features)
        - [Security Guards](#security-guards)
        - [Performance](#performance)
        - [Enterprise Features](#enterprise-features)
    - [Requirements](#requirements)
    - [Installation](#installation)
    - [Quick Start](#quick-start)
        - [Basic Usage](#basic-usage)
        - [Controller Trait](#controller-trait)
        - [PHP Attributes](#php-attributes)
    - [Configuration](#configuration)
    - [Security Guards](#security-guards-1)
    - [Middleware Usage](#middleware-usage)
    - [Artisan Commands](#artisan-commands)
    - [Testing](#testing)
    - [Documentation](#documentation)
    - [Contributing](#contributing)
    - [Security](#security)
    - [Credits](#credits)
    - [License](#license)

---

Features
--------

[](#features)

### Security Guards

[](#security-guards)

- **SQL Injection** — UNION attacks, boolean-based, time-based, stacked queries
- **XSS Detection** — Script tags, event handlers, DOM-based XSS, encoded payloads
- **Command Injection** — Shell metacharacters, command chaining, path traversal
- **SSRF Protection** — Internal IPs, cloud metadata endpoints, DNS rebinding
- **NoSQL Injection** — MongoDB operators, JSON-encoded attacks
- **Mass Assignment** — Dangerous field protection
- **GraphQL Security** — Query depth limits, complexity analysis
- **JWT/Token Abuse** — Algorithm confusion, replay attacks, JKU injection
- **Bot Detection** — Behavioral analysis, honeypot integration
- **Session Integrity** — Fingerprint drift, geolocation jumps

### Performance

[](#performance)

- Tiered inspection (quick scan + deep analysis)
- LRU deduplication cache
- Request sampling
- Bloom filter pre-screening
- Lazy guard resolution
- Streaming inspection for large payloads
- Async guard execution with PHP Fibers

### Enterprise Features

[](#enterprise-features)

- ML-powered anomaly detection
- Multi-tenant security isolation
- Real-time metrics (Prometheus-compatible)
- SIEM integration (Splunk, ELK, Datadog)
- WAF rule export (AWS WAF, Cloudflare, ModSecurity)
- Threat intelligence feeds
- Compliance reporting (PCI-DSS, OWASP Top 10)

---

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

[](#requirements)

- PHP 8.1+
- Laravel 10.0+ or 11.0+

---

Installation
------------

[](#installation)

```
composer require m9nx/laravel-runtime-guard
```

Publish the configuration:

```
php artisan vendor:publish --tag=runtime-guard-config
```

For database reporting (optional):

```
php artisan vendor:publish --tag=runtime-guard-migrations
php artisan migrate
```

---

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use M9nx\RuntimeGuard\Facades\RuntimeGuard;

// Inspect input with all enabled guards
$results = RuntimeGuard::inspect($userInput);

// Check if threat was detected
if ($results->hasThreat()) {
    Log::warning('Threat detected', [
        'level' => $results->getHighestThreatLevel()->value,
        'guards' => $results->getTriggeredGuards(),
    ]);
}

// Inspect with a specific guard
$result = RuntimeGuard::inspectWith('sql-injection', $userInput);
```

### Controller Trait

[](#controller-trait)

```
use M9nx\RuntimeGuard\Traits\InspectsInput;

class FormController extends Controller
{
    use InspectsInput;

    public function submit(Request $request)
    {
        $this->inspectRequest($request);

        // Or inspect specific fields only
        $this->inspectRequestFields(['name', 'email', 'message']);
    }
}
```

### PHP Attributes

[](#php-attributes)

```
use M9nx\RuntimeGuard\Attributes\GuardProfile;
use M9nx\RuntimeGuard\Attributes\SkipGuard;

class AdminController extends Controller
{
    #[GuardProfile('admin')]
    public function sensitiveAction()
    {
        // Uses 'admin' profile with stricter rules
    }

    #[SkipGuard(['xss'])]
    public function richTextEditor()
    {
        // XSS guard skipped for this endpoint
    }
}
```

---

Configuration
-------------

[](#configuration)

```
// config/runtime-guard.php

return [
    'enabled' => env('RUNTIME_GUARD_ENABLED', true),
    'mode' => env('RUNTIME_GUARD_MODE', 'log'), // 'block', 'log', 'silent'

    'pipeline' => [
        'strategy' => 'short_circuit', // 'full', 'short_circuit', 'threshold'
        'tiered' => true,
    ],

    'guards' => [
        'sql-injection' => ['enabled' => true, 'priority' => 100],
        'xss' => ['enabled' => true, 'priority' => 90],
        'command-injection' => ['enabled' => true, 'priority' => 95],
        // ... more guards
    ],

    'profiles' => [
        'api' => [
            'guards' => ['sql-injection', 'command-injection'],
            'mode' => 'log',
        ],
        'admin' => [
            'guards' => '*',
            'mode' => 'block',
        ],
    ],
];
```

---

Security Guards
---------------

[](#security-guards-1)

GuardDescriptionDefault Priority`sql-injection`SQL injection patterns100`command-injection`Shell command injection95`xss`Cross-site scripting90`deserialization`Unsafe deserialization92`nosql-injection`NoSQL/MongoDB injection88`file-operation`Path traversal, file inclusion85`ssrf`Server-side request forgery80`mass-assignment`Dangerous field assignment75`graphql`GraphQL abuse prevention70`jwt`JWT/Token attacks65`bot-behavior`Bot/automation detection60`session-integrity`Session hijacking detection55`anomaly`Behavioral anomaly detection50---

Middleware Usage
----------------

[](#middleware-usage)

```
// routes/web.php

// Apply to specific routes
Route::middleware(['runtime-guard'])->group(function () {
    Route::post('/submit', [FormController::class, 'submit']);
});

// With a specific profile
Route::middleware(['runtime-guard:admin'])->group(function () {
    Route::resource('/admin/users', AdminUserController::class);
});
```

---

Artisan Commands
----------------

[](#artisan-commands)

```
# List all registered guards
php artisan runtime-guard:list

# Test a guard with sample input
php artisan runtime-guard:test sql-injection "1' OR '1'='1"

# Check system status
php artisan runtime-guard:status

# Toggle guards at runtime
php artisan runtime-guard:toggle sql-injection --disable

# Generate a new custom guard
php artisan runtime-guard:make-guard CustomGuard

# Run security audit
php artisan runtime-guard:security-audit
```

---

Testing
-------

[](#testing)

RuntimeGuard provides testing utilities for your application tests:

```
use M9nx\RuntimeGuard\Facades\RuntimeGuard;

class SecurityTest extends TestCase
{
    public function test_sql_injection_is_detected(): void
    {
        $fake = RuntimeGuard::fake();

        $this->post('/api/search', ['query' => "1' OR '1'='1"]);

        $fake->assertThreatDetected();
        $fake->assertGuardTriggered('sql-injection');
    }

    public function test_clean_input_passes(): void
    {
        $fake = RuntimeGuard::fake();

        $this->post('/api/search', ['query' => 'normal search']);

        $fake->assertNoThreatsDetected();
    }
}
```

---

Documentation
-------------

[](#documentation)

DocumentDescription[Architecture](docs/ARCHITECTURE.md)Internal architecture and component overview[Features](docs/FEATURES.md)Complete feature list and capabilities[Changelog v4.0](docs/V4_CHANGELOG.md)What's new in version 4.0[Contributing](CONTRIBUTING.md)Contribution guidelines[Security Policy](SECURITY.md)Security reporting procedures---

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

```
# Development setup
composer install
composer test
composer analyse
```

---

Security
--------

[](#security)

If you discover a security vulnerability, please send an email to the maintainer instead of using the issue tracker. See [SECURITY.md](SECURITY.md) for details.

---

Credits
-------

[](#credits)

- [M9nx](https://github.com/M9nx)
- [All Contributors](../../contributors)

---

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance77

Regular maintenance activity

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

125d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2e0ab065a7f6f43232711c9276baf55d4a3dcda97c3c1e82c336c25a39dd28d?d=identicon)[M9nx](/maintainers/M9nx)

---

Top Contributors

[![M9nx](https://avatars.githubusercontent.com/u/90654832?v=4)](https://github.com/M9nx "M9nx (17 commits)")

---

Tags

laravelmonitoringsecurityruntimexssSQL Injectionprotectionguard

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/m9nx-laravel-runtime-guard/health.svg)

```
[![Health](https://phpackages.com/badges/m9nx-laravel-runtime-guard/health.svg)](https://phpackages.com/packages/m9nx-laravel-runtime-guard)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[inspector-apm/inspector-laravel

Code Execution Monitoring, built for developers.

2332.0M2](/packages/inspector-apm-inspector-laravel)[jackwh/laravel-new-relic

Monitor your Laravel application performance with New Relic

112827.2k](/packages/jackwh-laravel-new-relic)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2011.0k](/packages/alajusticia-laravel-logins)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[kssadi/log-tracker

A powerful, intuitive, and efficient log viewer for Laravel applications.

264.8k](/packages/kssadi-log-tracker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
