Download the PHP package dimtrovich/user-agent without Composer
On this page you can find all versions of the php package dimtrovich/user-agent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dimtrovich/user-agent
More information about dimtrovich/user-agent
Files in dimtrovich/user-agent
Package user-agent
Short Description A PHP desktop/mobile user agent parser with bot detection, based on Mobiledetect and CrawlerDetect.
License MIT
Homepage https://github.com/dimtrovich/user-agent
Informations about the package user-agent
UserAgent
A PHP desktop/mobile user agent parser with bot detection, based on Mobile Detect and CrawlerDetect with desktop support and additional functionality.
[!note] This is a modified version of jenssegers/agent to support PHP 8.0 up and MobileDetect 4.x.
Installation
Install using composer:
Laravel (optional)
Add the service provider in config/app.php:
And add the UserAgent alias to config/app.php:
BlitzPHP (optional)
Add the service provider in app/Config/app.php:
And add the UserAgent alias to app/Config/app.php:
Basic Usage
Start by creating an Agent instance (or use the Agent Facade if you are using Laravel):
If you want to parse user agents other than the current request in CLI scripts for example, you can use the setUserAgent and setHttpHeaders methods:
All of the original Mobile Detect methods are still available, check out some original examples at https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
Is?
Check for a certain property in the user agent.
Magic is-method
Magic method that does the same as the previous is() method:
Mobile detection
Check for mobile device:
Match user agent
Search the user agent with a regular expression:
Additional Functionality
Accept languages
Get the browser's accept languages. Example:
Device name
Get the device name, if mobile. (iPhone, Nexus, AsusTablet, ...)
Operating system name
Get the operating system. (Ubuntu, Windows, OS X, ...)
Browser name
Get the browser name. (Chrome, IE, Safari, Firefox, ...)
Desktop detection
Check if the user is using a desktop device.
This checks if a user is not a mobile device, tablet or robot.
Phone detection
Check if the user is using a phone device.
Robot detection
Check if the user is a robot. This uses jaybizzle/crawler-detect to do the actual robot detection.
Robot name
Get the robot name.
Browser/platform version
MobileDetect recently added a version method that can get the version number for components. To get the browser or platform version you can use:
Note, the version method is still in beta, so it might not return the correct result.
License
This is licensed under The MIT License (MIT).
Security contact information
To report a security vulnerability, follow these steps.
All versions of user-agent with dependencies
mobiledetect/mobiledetectlib Version ^4.8
jaybizzle/crawler-detect Version ^1.3