https://github.com/mimmi20/browser-detector
Library for PHP 8.4+ to detect Browsers and Devices
https://github.com/mimmi20/browser-detector
detect php php85 ua-parser user-agent user-agent-parser
Last synced: about 1 month ago
JSON representation
Library for PHP 8.4+ to detect Browsers and Devices
- Host: GitHub
- URL: https://github.com/mimmi20/browser-detector
- Owner: mimmi20
- License: mit
- Created: 2013-09-09T20:06:56.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2026-04-14T07:11:17.000Z (about 1 month ago)
- Last Synced: 2026-04-14T09:35:05.853Z (about 1 month ago)
- Topics: detect, php, php85, ua-parser, user-agent, user-agent-parser
- Language: PHP
- Homepage: https://github.com/mimmi20/BrowserDetector
- Size: 837 MB
- Stars: 48
- Watchers: 4
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# BrowserDetector
[](https://packagist.org/packages/mimmi20/browser-detector)
[](https://packagist.org/packages/mimmi20/browser-detector)
[](https://packagist.org/packages/mimmi20/browser-detector)
## Code Status
[](https://codecov.io/gh/mimmi20/BrowserDetector)
[](https://codeclimate.com/github/mimmi20/browser-detector/test_coverage)
[](https://isitmaintained.com/project/mimmi20/BrowserDetector "Average time to resolve an issue")
[](https://isitmaintained.com/project/mimmi20/BrowserDetector "Percentage of issues still open")
[](https://dashboard.stryker-mutator.io/reports/github.com/mimmi20/browser-detector/master)
[](https://codeclimate.com/github/mimmi20/browser-detector/maintainability)
## Requirements
This library requires PHP 8.3+.
Also a PSR-3 compatible logger and a PSR-16 compatible cache are required.
## Installation
Run the command below to install via Composer
```shell
composer require mimmi20/browser-detector
```
## Usage
```php
$detectorFactory = new \BrowserDetector\DetectorFactory($cache, $logger);
$detector = $detectorFactory();
// get the result
$result = $detector->getBrowser($request);
```
The request parameter may be a string, an array or a PSR-7 compatible message.
## Usage Examples
### Taking the user agent from the global $_SERVER variable
```php
$detectorFactory = new \BrowserDetector\DetectorFactory($cache, $logger);
$detector = $detectorFactory();
$result = $detector->getBrowser($_SERVER);
```
### Using a sample useragent
```php
$detectorFactory = new \BrowserDetector\DetectorFactory($cache, $logger);
$detector = $detectorFactory();
$result = $detector->getBrowser($the_user_agent);
```
## The result
The `getBrowser` function returns an array with this structure
```php
[
'headers' => [],
'device' => [
'architecture' => null,
'deviceName' => null,
'marketingName' => null,
'manufacturer' => 'unknown',
'brand' => 'unknown',
'dualOrientation' => null,
'simCount' => null,
'display' => [
'width' => null,
'height' => null,
'touch' => null,
'size' => null,
],
'type' => 'unknown',
'ismobile' => null,
'istv' => null,
'bits' => null,
],
'os' => [
'name' => null,
'marketingName' => null,
'version' => null,
'manufacturer' => 'unknown',
],
'client' => [
'name' => null,
'modus' => null,
'version' => null,
'manufacturer' => 'unknown',
'type' => 'unknown',
'isbot' => null,
],
'engine' => [
'name' => null,
'version' => null,
'manufacturer' => 'unknown',
],
]
```
## Issues and feature requests
Please report your issues and ask for new features on the GitHub Issue Tracker
at