jayanta/laravel-ai-guard
Laravel AI Guard adds a lightweight middleware layer that detects, logs, and blocks unwanted AI traffic hitting your app, and lets you gate AI-powered endpoints behind simple, configurable rules—keeping scrapers and costly requests under control.
BotClassified, AgentVerified, and SpoofedBotDetected give you a named, categorised, method-attributed verdict (chatgpt.com / ai_agents / web_bot_auth) that other parts of the product can act on. That unlocks roadmap conversations that were previously blocked on "we can't tell who's hitting us": agent-specific rate limits or metering, AI-crawler-aware analytics segmentation, content licensing or pay-per-crawl experiments, verified-search-engine handling for SEO, and spoofed-crawler alerting for security.ai-guard.verdict/1 contract means other teams subscribe to a stable, versioned payload rather than importing the package — so adopting it is a reversible decision, not a platform commitment. That materially changes the calculus in a buy-vs-build review.search_engines even though that category isn't blocked by default. That lets you separate "who is this?" from "what do we do about it?" — so blocking rules can live in product/ops config while identity is consumed by billing, analytics, and personalisation without stepping on each other.request()->attributes->get('ai_guard.verdict') and listeners run through the standard Laravel event bus, an experiment (e.g. "serve a different response to verified AI agents") is a listener, not a fork. Cheap to prototype, cheap to remove.Consider it when:
use statement, no Composer dependency, keeps working if the package is later removed.interop.enabled => false kills the events; whitelisted requests aren't evaluated at all.Look elsewhere when:
For executives: This release turns a bot-blocking utility into a reusable identity layer for the platform. The strategic point is optionality — we can now make deliberate decisions about AI traffic (allow, meter, license, block, or simply measure) and change our mind later, because every other system consumes a stable, versioned contract rather than the package itself. Adoption cost is low and reversible: the change is purely additive, nothing alters behaviour unless a team opts in, and there's a one-flag off switch. Verification of bot identity — signatures, IP ranges, reverse DNS, spoof detection — is work we would otherwise have to buy or build and maintain; this lets us defer that spend while keeping the door open.
For engineering: v3.1.0 is additive and non-breaking. Three events fire at most once per request, carrying a fixture-locked ai-guard.verdict/1 payload with a guarantee that fields may be added but never renamed or removed within v1 — the test suite fails if the package drifts from the canonical fixture. Payloads are scalar, read-only, and queueable; listener exceptions are contained. The same verdict is available synchronously via a request attribute. Quality signals are reasonable for a dependency of this role: 482 tests, PHPStan level 6, Laravel Pint, and support across Laravel 10–13 / PHP 8.1–8.4. The one thing to note operationally is the SIEM/OTel version-attribution fix — if we're already exporting, existing telemetry mislabels 3.0.1 as 3.0.0 and should be re-baselined after the upgrade.
How can I help you explore Laravel packages today?