Effectra Tracker is a PHP package that provides methods to extract information from the client's request, including IP address, browser details, operating system, device type, accepted languages, and referer URL. It also includes integration with IP tracking services to fetch additional attributes related to the provided IP address.
You can install the Effectra Tracker package via Composer:
composer require effectra/tracker
use Effectra\Tracker\Tracker;
use Psr\Http\Message\ServerRequestInterface;
$request = ...; // Your PSR-7 ServerRequestInterface implementation
$tracker = new Tracker($request);
$ipAddress = $tracker->getIp();
$browser = $tracker->getBrowser();
// $browser['name'] contains the browser name
// $browser['version'] contains the browser version
$os = $tracker->getOs();
// $os['name'] contains the OS name
// $os['version'] contains the OS version
$deviceType = $tracker->getDevice();
$userAgent = $tracker->getUserAgent();
$acceptedLanguages = $tracker->getAcceptLangs();
$refererUrl = $tracker->getReferer();
$isPhone = $tracker->isPhone();
$clientInfo = $tracker->getAll();
// $clientInfo is an associative array containing all client information
Effectra Tracker supports integration with various IP tracking services. Currently, the following services are supported:
use Effectra\Tracker\Services\IpGeoLocation;
use GuzzleHttp\Client;
$client = new Client(); // GuzzleHttp client instance
$ip = ...; // IP address to query
$apiKey = ...; // Your API key for ipgeolocation.io
$ipGeoLocation = new IpGeoLocation($client, $ip, $apiKey);
$ipAttributes = $ipGeoLocation->getAll();
use Effectra\Tracker\Services\IpRegistry;
use GuzzleHttp\Client;
$client = new Client(); // GuzzleHttp client instance
$ip = ...; // IP address to query
$apiKey = ...; // Your API key for ipregistry.co
$ipRegistry = new IpRegistry($client, $ip, $apiKey);
$ipAttributes = $ipRegistry->getAll();
use Effectra\Tracker\Services\IpWhoIs;
use GuzzleHttp\Client;
$client = new Client(); // GuzzleHttp client instance
$ip = ...; // IP address to query
$ipWhoIs = new IpWhoIs($client, $ip, null); // No API key required for ipwho.is
$ipAttributes = $ipWhoIs->getAll();
- Mohammed Taha - Email
This project is licensed under the MIT License - see the LICENSE file for details.