PHPackages                             promptphp/intercept-injection-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. [Security](/categories/security)
4. /
5. promptphp/intercept-injection-guard

ActiveLibrary[Security](/categories/security)

promptphp/intercept-injection-guard
===================================

Prompt injection guard middleware for Laravel AI agents.

v0.1.7(2w ago)242MITPHPPHP ^8.4.0

Since Jun 19Pushed 2w agoCompare

[ Source](https://github.com/promptphp/intercept-injection-guard)[ Packagist](https://packagist.org/packages/promptphp/intercept-injection-guard)[ Docs](https://intercept.promptphp.com)[ RSS](/packages/promptphp-intercept-injection-guard/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (8)Dependencies (4)Versions (9)Used By (0)

Introduction
------------

[](#introduction)

`PromptInjectionGuard` is a Laravel AI SDK agent middleware that detects common prompt injection attempts before an agent prompt reaches the AI provider.

It can block, log, warn, sanitize, or fully delegate handling to a custom callback.

Important

This middleware is part of the [Intercept middleware collection](https://github.com/promptphp/intercept). It is a lightweight heuristic guard designed to catch common prompt injection patterns, not to guarantee complete protection against every possible attack.

Quick start
-----------

[](#quick-start)

### Installation

[](#installation)

```
composer require promptphp/intercept-injection-guard
```

You may publish the config or not, the middleware works out of the box.

```
php artisan vendor:publish --tag=intercept-config
```

### Usage

[](#usage)

Return the `PromptInjectionGuard` middleware on an agent's middleware method.

Important

To add middleware to an agent, implement the `HasMiddleware` interface and define a middleware method that returns an array of middleware classes.

```
