Download the PHP package impruthvi/agent-detector-laravel without Composer

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

agent-detector-laravel

Laravel companion for shipfastlabs/agent-detector.

Install it, add two lines to bootstrap/app.php, and your Laravel app automatically:

Grep by session ID. See exactly what your AI agent did.


Requirements

Installation

Publish the config (optional):

Setup

Add the middleware to bootstrap/app.php:

That's it. CSRF bypass and the agent log channel are active automatically.


What you get

CSRF bypass

Agent requests skip CSRF verification. No more 419s when Claude Code, Codex, or Cursor hits your endpoints.

The package tries two approaches, in order:

Approach 1 (automatic): Decorates VerifyCsrfToken via the service container. Works on most Laravel 11+ installs.

Approach 2 (manual fallback): If Approach 1 doesn't work, you'll see a warning in your logs:

Fix it by replacing the middleware in bootstrap/app.php:

You can subclass AgentAwareCsrfMiddleware to add your own $except array:

Agent log channel

Every log line emitted during an agent session is tagged with the agent name and session ID.

The agent channel is auto-registered. Use it directly:

Logs write to storage/logs/agent.log.

X-Agent-Session response header

Every response to a detected agent request includes:

Useful for debugging via proxy logs, CDN access logs, or browser devtools.


Configuration

config/agent-detector.php (after publishing):


Using AgentContext

Inject AgentContext anywhere in your app:

Method Returns Example
isAgent() bool true
name() ?string 'claude'
displayName() string 'Claude Code'
sessionId() ?string 'thread-abc123' or null
knownAgent() ?KnownAgent KnownAgent::Claude

Session IDs

Most agents do not expose a session ID. Only Codex (CODEX_THREAD_ID) and Amp (AMP_CURRENT_THREAD_ID) expose session env vars today. Log output shows session:"none" for all others — that's expected.


Known limitations

Octane / long-running processes: AgentContext is resolved once when the application boots. Under Laravel Octane or long-running queue:work, detection reflects the environment at startup. Agents set env vars before the process starts, so this is rarely an issue in practice.


Detected agents

Inherits detection from shipfastlabs/agent-detector:

Agent Display name Session ID
Claude Code Claude Code
Cursor Cursor
Codex Codex CODEX_THREAD_ID
Amp Amp AMP_CURRENT_THREAD_ID
Devin Devin
Gemini CLI Gemini CLI
Augment CLI Augment CLI
OpenCode OpenCode
Replit Replit
GitHub Copilot GitHub Copilot
Antigravity Antigravity
Pi Pi

CI

Laravel PHP
11, 12 8.2, 8.3, 8.4, 8.5
13 8.4, 8.5

License

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


All versions of agent-detector-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.5
shipfastlabs/agent-detector Version ^1.1
laravel/framework 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 impruthvi/agent-detector-laravel contains the following files

Loading the files please wait ...