Download the PHP package flarex/flareshield without Composer

On this page you can find all versions of the php package flarex/flareshield. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package flareshield

FlareShield

Latest Version on Packagist

Laravel-native AI security framework for the LLM era. Defend chatbots, agents, RAG pipelines and tool-calling workflows against prompt injection, jailbreaks, system prompt leakage, RAG poisoning, malicious tool usage and unsafe AI output — with a single Composer install.


Table of Contents


Why FlareShield

LLM-powered features ship in days, but the threat surface of an AI system is fundamentally different from a traditional web app. FlareShield gives Laravel developers a defense-in-depth toolkit designed specifically for that gap:

Threat Model

FlareShield is designed to mitigate the OWASP LLM Top 10 categories most relevant to application-layer code:

Threat Layer
LLM01 — Prompt Injection (direct) scanPrompt, role-override + heuristic scanners
LLM01 — Prompt Injection (indirect) sanitizeDocument, indirect-injection scanner, RAG fence
LLM02 — Insecure Output Handling scanOutput, output validator (HTML/script/secret leak)
LLM06 — Sensitive Information Disclosure system-prompt-leak scanner + secret detection in output
LLM07 — Insecure Plugin / Tool Design authorizeTool, ToolPermissionPolicy
LLM08 — Excessive Agency per-agent config + confirmation flag for high-impact tools
LLM09 — Overreliance structured ScanResult you can act on

FlareShield does not ship any AI model itself. It is a deterministic, auditable, framework-side guardrail — pair it with provider-side moderation (OpenAI Moderation, Llama Guard, AWS Bedrock Guardrails, etc.) for the strongest posture.

Installation

Publish the config (optional but recommended):

The package auto-registers via Laravel's package discovery (FlareShieldServiceProvider) and exposes the FlareShield facade.

Requirements: PHP 8.2+, Laravel 11 / 12 / 13.

Quick Start

Need the structured result instead of an exception? Use scanPrompt / scanOutput:

Middleware

Two middleware aliases are registered:

Alias Class Purpose
flareshield.prompt ProtectAiPrompt Validates inbound user prompt
flareshield.output ProtectAiOutput Validates outbound JSON reply

Parameters: {field}, {agent?}. Blocked prompts return 422 with a structured JSON body. The full ScanResult is also stashed on the request under flareshield.prompt_result so your controller can inspect it.

Guarding RAG Documents

Indirect prompt injection is the #1 RAG threat. Sanitize every retrieved chunk before injecting it into the model context:

guardDocument() will:

  1. Run all configured scanners against the chunk.
  2. Strip HTML comments, zero-width / control characters and tag-style hidden text.
  3. Quote suspicious imperative phrases so the model treats them as data.
  4. Truncate to a configured maximum length.
  5. Wrap the result in clearly labeled <<<UNTRUSTED_DOCUMENT>>> fences.
  6. Throw RagInjectionException when the chunk crosses the block threshold.

Guarding Tool Calls

Configure in config/flareshield.php under the tools key.

Output Validation

scanOutput() runs the configured output_validators. The default OutputValidator flags:

Per-Agent Configuration

Every config key can be overridden per agent:

Security Levels

Level Flag ≥ Block ≥ Use case
lenient 60 90 Local dev, demos
balanced 40 70 Production default
strict 25 50 Finance, health, internal admin bots
enterprise 20 45 Strict + verbose telemetry

Tune precisely in config('flareshield.thresholds').

Events

Available events: PromptScanned, OutputScanned, ThreatDetected, ToolCallBlocked.

Extending FlareShield

Write a custom scanner:

Then register it in config/flareshield.php:

Need a different scoring strategy? Bind your own RiskEngine:

Testing

The suite uses Orchestra Testbench and exercises scanners, the risk engine, the manager and the HTTP middleware end-to-end with realistic attack payloads.

Architecture

See docs/threat-model.md for deeper dives.

License

MIT © FlareX. See LICENSE.


All versions of flareshield with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/pipeline Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/events Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flarex/flareshield contains the following files

Loading the files please wait ...