Download the PHP package avvertix/laravel-agent-request without Composer

On this page you can find all versions of the php package avvertix/laravel-agent-request. 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 laravel-agent-request

Laravel Agent Request

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Detect and manage AI agent HTTP requests in Laravel applications. It identifies AI assistants, crawlers, and data-extraction tools via User-Agent patterns and infrastructure headers, then gives you middleware to block, trace, or serve them differently.

Requirements

Installation

Install the package via Composer:

The service provider is auto-discovered by Laravel.

Configuration

Agent Request is configurable via environment variables.

Variable Default Description
AGENT_REQUEST_ENABLED true Set to false to bypass all middleware globally
AGENT_REQUEST_BLOCK Comma-separated list of categories to block, e.g. assistant,crawler,tool

In case you want to configure the detection logic you can publish the configuration file:

Environment variables

Agent categories

We groups known AI agents into three categories:

Category AgentType Description
Assistants AgentType::ASSISTANT Agents browsing on behalf of a live user (ChatGPT-User, Claude-User, Gemini, Perplexity-User, …)
Crawlers AgentType::CRAWLER Automated training and indexing bots (GPTBot, ClaudeBot, Google-Extended, Applebot, …)
Tools AgentType::TOOL AI-powered research and data-extraction tools (Diffbot, FirecrawlAgent, Scrapy, TavilyBot, …)

Requests that match no known pattern return AgentType::HUMAN.

Usage

Detecting agents in a controller

Inject or type-hint AgentRequest instead of the standard Request:

All detection methods available on AgentRequest:

Method Returns Description
isAgent() bool Any recognised AI agent
isAiAssistant() bool User-facing AI assistant
isAiCrawler() bool Training or indexing crawler
isAiTool() bool Data-extraction or research tool
isCloudflareBrowserRendering() bool Cloudflare Browser Rendering infrastructure
detect() AgentType Category of the detected agent
agentName() ?string Canonical name key of the agent, or null
wantsMarkdown() bool Accept header contains text/markdown or text/x-markdown
expectsMarkdown() bool wantsMarkdown() or Accept: text/plain

Middleware

Register middleware in bootstrap/app.php or a route group:

DenyAgentMiddleware

Returns a 404 Not Found response for any agent whose category appears in the agent-request.block config list.

By default assistant and tool agents are blocked; crawler agents are allowed through (they respect robots.txt). To block crawlers too, update the config or set the environment variable:

To disable blocking entirely without removing the middleware:

TraceAgentMiddleware

Adds agent_name and agent_type to the Laravel Context for every recognised AI agent request. Laravel includes them in log entries automatically:

This middleware never blocks. Stack it with DenyAgentMiddleware freely.

Request macros

The package adds two macros to the base Illuminate\Http\Request:

Using DetectAgent directly

Generating a robots.txt

Generate a robots.txt that instructs known AI agents to not crawl your site:

--category accepts assistant, crawler, and tool. Pass it multiple times to combine. Omit it to include all three.

Extending the detector

Extend DetectAgent and override the pattern arrays, then register your class in the config:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-agent-request with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/http Version ^11.0||^12.0||^13.0
illuminate/support 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 avvertix/laravel-agent-request contains the following files

Loading the files please wait ...