fyre / useragent
A user agent library.
v2.1.1
2024-10-30 11:27 UTC
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^11
README
FyreUserAgent is a free, open-source user agent library for PHP.
Table Of Contents
Installation
Using Composer
composer require fyre/useragent
In PHP:
use Fyre\Http\UserAgent;
Basic Usage
$agent
is a string representing the user agent.
$userAgent = new UserAgent($agent);
Alternatively, you can use the fromString
method for easier chaining.
$userAgent = UserAgent::fromString($agent);
Methods
Get Agent String
Get the user agent string.
$agent = $userAgent->getAgentString();
Get Browser
Get the browser.
$browser = $userAgent->getBrowser();
Get Mobile
Get the mobile.
$mobile = $userAgent->getMobile();
Get Platform
Get the platform.
$platform = $userAgent->getPlatform();
Get Robot
Get the robot.
$robot = $userAgent->getRobot();
Get Version
Get the browser version.
$version = $userAgent->getVersion();
Is Browser
Determine whether the user agent is a browser.
$isBrowser = $userAgent->isBrowser();
Is Mobile
Determine whether the user agent is a mobile.
$isMobile = $userAgent->isMobile();
Is Robot
Determine whether the user agent is a robot.
$isRobot = $userAgent->isRobot();