atldays / laravel-visitor
Laravel package for resolving typed visitor information from the current request, including IP address, user agent, geo data, and configurable fingerprints.
Requires
- php: ^8.2
- atldays/laravel-agent: ^2.0
- atldays/laravel-geo: ^2.0
- illuminate/contracts: ^11.0|^12.0|^13.0
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- spatie/laravel-data: ^4.21
- spatie/laravel-package-tools: ^1.93
Requires (Dev)
- laravel/pint: ^1.24
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.5|^12.0
This package is auto-updated.
Last update: 2026-04-20 19:39:44 UTC
README
Resolve a full visitor profile from the current Laravel request.
atldays/laravel-visitor gives you a clean, typed abstraction over the most important visitor signals:
- IP address
- User-Agent
- preferred language and accepted languages
- parsed agent metadata through
atldays/laravel-agent - geo metadata through
atldays/laravel-geo - configurable fingerprint generation
It is designed to be the thin orchestration layer that connects those concerns into one consistent visitor object.
Why This Package
When you need to understand who is visiting your application, you usually end up stitching together several low-level request details by hand.
This package gives you one place to resolve:
- the raw visitor identity signals
- the parsed device and browser information
- the geo lookup result
- the language context
- a stable fingerprint strategy that you can customize
Installation
composer require atldays/laravel-visitor
Quick Start
Resolve the current visitor through the manager:
use Atldays\Visitor\Facades\VisitorManager; $visitor = VisitorManager::request(); $visitor->ip(); $visitor->userAgent(); $visitor->language()->language(); $visitor->language()->languages(); $visitor->fingerprint(); $visitor->agent(); $visitor->geo();
Resolve the current visitor directly from the request:
$visitor = request()->visitor();
Resolve the current visitor through the Visitor facade:
use Atldays\Visitor\Facades\Visitor; Visitor::ip(); Visitor::userAgent(); Visitor::language(); Visitor::fingerprint(); Visitor::agent(); Visitor::geo();
Create a visitor manually:
use Atldays\Visitor\Facades\VisitorManager; $visitor = VisitorManager::from( '8.8.8.8', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36', [ 'language' => 'en-US', 'languages' => ['en-US', 'en'], ], );
API Overview
VisitorManager
Use VisitorManager when you want to resolve a full visitor object:
VisitorManager::request()VisitorManager::from($ip, $userAgent, $language = [])
Visitor
Use Visitor when you want quick access to the current resolved visitor:
Visitor::ip()Visitor::userAgent()Visitor::language()Visitor::fingerprint()Visitor::agent()Visitor::geo()
Language Object
Language data is exposed as a dedicated DTO instead of plain strings scattered across the visitor object.
$language = $visitor->language(); $language->language(); // Most preferred language $language->languages(); // All accepted languages in priority order
Fingerprint Driver
By default, the package builds a fingerprint from the visitor IP address and User-Agent.
Publish the config file if you want to replace the default fingerprint driver:
php artisan vendor:publish --tag=visitor-config
You can replace the implementation in the config:
return [ 'fingerprint' => [ 'driver' => App\Support\Visitors\CustomFingerprint::class, ], ];
Your custom driver must implement Atldays\Visitor\Contracts\FingerprintContract.
Built On
This package works as an orchestration layer on top of:
License
The MIT License (MIT). Please see LICENSE.md for more information.