PHP code example of 1978io / scry

1. Go to this page and download the library: Download 1978io/scry 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/ */

    

1978io / scry example snippets




use Scry\Scry;

$d = Scry::detect();   // reads the current request: User-Agent + Sec-CH-UA* headers

if (!$d->isBrowser()) {
    // curl, a script, a headless browser, a crawler…
}

echo $d->label();      // "Chrome on Windows"

$d = Scry::detect($uaString);
$d = Scry::detect($uaString, $clientHints);   // hints optional, assoc array

$d->kind();        // 'browser' | 'bot' | 'tool' | 'unknown'
$d->isBrowser();   // bool — the anomaly flag
$d->isBot();       // bool — a crawler specifically
$d->browser();     // 'Chrome' | 'Firefox' | 'Safari' | … | 'Other'
$d->os();          // 'Windows' | 'macOS' | 'iOS' | 'Android' | … | 'Other'
$d->device();      // 'desktop' | 'tablet' | 'mobile' | 'unknown'
$d->isMobile();    // bool — mobile or tablet
$d->label();       // 'Chrome on Windows' — for display
$d->confidence();  // 'high' | 'low'
$d->raw();         // the original User-Agent string, always
$d->toArray();     // ['kind','browser','os','device','bot','label','confidence','raw']

$d = Scry::detect();

log_line([
    'ip'      => $_SERVER['REMOTE_ADDR'] ?? '-',
    'client'  => $d->label(),          // "Safari on iOS"
    'kind'    => $d->kind(),           // "browser"
    'device'  => $d->device(),         // "mobile"
    'ua'      => $d->raw(),            // keep the truth alongside the label
]);
bash
php tests/run.php