Skip to content

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.

Notifications You must be signed in to change notification settings

effectra/tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Effectra Tracker

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.

Installation

You can install the Effectra Tracker package via Composer:

composer require effectra/tracker

Usage

Tracker Class

Initialize Tracker

use Effectra\Tracker\Tracker;
use Psr\Http\Message\ServerRequestInterface;

$request = ...; // Your PSR-7 ServerRequestInterface implementation
$tracker = new Tracker($request);

Get Client's IP Address

$ipAddress = $tracker->getIp();

Get Browser Details

$browser = $tracker->getBrowser();
// $browser['name'] contains the browser name
// $browser['version'] contains the browser version

Get Operating System Details

$os = $tracker->getOs();
// $os['name'] contains the OS name
// $os['version'] contains the OS version

Get Device Type

$deviceType = $tracker->getDevice();

Get User Agent

$userAgent = $tracker->getUserAgent();

Get Accepted Languages

$acceptedLanguages = $tracker->getAcceptLangs();

Get Referer URL

$refererUrl = $tracker->getReferer();

Check if Client is Using a Phone Device

$isPhone = $tracker->isPhone();

Get All Client Information

$clientInfo = $tracker->getAll();
// $clientInfo is an associative array containing all client information

IP Tracking Services Integration

Effectra Tracker supports integration with various IP tracking services. Currently, the following services are supported:

IpGeoLocation Service

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();

IpRegistry Service

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();

IpWhoIs Service

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();

Requirements

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages