PHP code example of shipfastlabs / agent-detector
1. Go to this page and download the library: Download shipfastlabs/agent-detector library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shipfastlabs / agent-detector example snippets
use Laravel\AgentDetector\AgentDetector;
use Laravel\AgentDetector\KnownAgent;
$result = AgentDetector::detect();
if ($result->isAgent) {
echo "Running inside: {$result->name}";
}
// Check for a specific known agent
if ($result->knownAgent() === KnownAgent::Claude) {
echo "Hello from Claude!";
}
use function Laravel\AgentDetector\detectAgent;
$result = detectAgent();
bash
AI_AGENT=my-custom-agent php your-script.php