Library for PHP 7.4+ to detect Browsers and Devices

Last update: Mar 30, 2022

BrowserDetector

Latest Stable Version Latest Unstable Version License

Code Status

codecov Average time to resolve an issue Percentage of issues still open

Requirements

This library requires PHP 7.4+. Also a PSR-3 compatible logger and a PSR-16 compatible cache are required.

Installation

Run the command below to install via Composer

composer require mimmi20/browser-detector

Usage

$detectorFactory = new \BrowserDetector\DetectorFactory($cache, $logger);
$detector        = $detectorFactory();

// get the result
$result = $detector->getBrowser($request); // (deprecated)
$result = $detector($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

$detectorFactory = new \BrowserDetector\DetectorFactory($cache, $logger);
$detector        = $detectorFactory();

$result = $detector($_SERVER);

Using a sample useragent

$detectorFactory = new \BrowserDetector\DetectorFactory($cache, $logger);
$detector        = $detectorFactory();

$result = $detector($the_user_agent);

The result

The getBrowser function and the __invoke function return a ua-result object.

Issues and feature requests

Please report your issues and ask for new features on the GitHub Issue Tracker at https://github.com/mimmi20/BrowserDetector/issues

GitHub

https://github.com/mimmi20/BrowserDetector
Comments
  • 1. Browser not detected

    UA: Mozilla/5.0 (Linux; Android 4.2.2; ZTE 975 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.14 Mobile Crosswalk/3.32.53.0 Mobile Safari/537.36 detected as chrome should be crosswalkapp

    Reviewed by mimmi20 at 2019-03-21 08:56
  • 2. device wrong detected

    UA: Mozilla/5.0 (Linux; U; Android 4.2.2; de-de; Vodafone Smart 4G Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 SWV/090.37DE

    detected as: smart should be: smart4g

    Reviewed by mimmi20 at 2019-04-08 07:58
  • 3. device not detected

    UA: Mozilla/5.0 (Linux; U; Android 4.4.3; ru-ru; N909 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

    detected as: n909 should be: grand

    Reviewed by mimmi20 at 2019-04-15 12:06
  • 4. Browser not detected

    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.21 Safari/537.36 MMS/1.0.2459.0

    detected as Chrome should be Opera Neon

    Reviewed by mimmi20 at 2019-02-26 07:15
  • 5. Update infection/infection requirement from ^0.12.0 to ^0.12.0 || ^0.13.0

    Updates the requirements on infection/infection to permit the latest version.

    Release notes

    Sourced from infection/infection's releases.

    Proper array coverage, bcmath/mbstring mutators, pcov support

    0.13.0

    Full Changelog (2019-05-18)

    Added:

    • Log the InitialTestsRun command line when --debug is used #520
    • Preliminary support for PCOV #667
    • Adding Line Numbers To Mutator Ignore List #663
    • Family bc*-functions mutators (bcmath support) #658
    • Family mb_*-functions mutators #654
    • Add a new unwrap mutator: ucwords #644
    • New @​unwrap mutator: lcfirst() #642
    • Provide compact output for CI environments #613
    • add unwrap array_pad mutator #680
    • add unwrap array_intersect_assoc mutator #679
    • #597 Array item removal mutator #649
    • Enhancement: Implement UnwrapTrim mutator #638
    • Enhancement: Implement UnwrapArrayUintersect mutator #637
    • Enhancement: Implement UnwrapArrayUintersectUassoc mutator #633
    • Enhancement: Implement UnwrapArrayUintersectAssoc mutator #628
    • Enhancement: Implement UnwrapArrayUdiff mutator #624
    • Mutator: AssignCoalesce. Upgrade PHPParser to 4.2.1 #641
    • Mutator: UnwrapUcFirst (unwrap the first argument of ucfirst() function) #635

    Fixed:

    • Multi line arrays are not properly handled by code coverage #652
    • Error when parsing method that creates anonymous class #616
    • Infection gets stuck in the first execution after configuration file is created #576
    • Wrong constructor ownership when returning an anonymous class #682
    • Do not mutate * to / and vice versa if one of the operands is numeric ±1.0 #673

    Changed:

    • Stop traversal of interfaces and abstract methods #656
    • Add a few more count esque functions to not decrement against #640
    • Enhancement: Normalize composer.json #629
    • Upgrade PHPUnit from ^6.5 to ^7.5 and all dependencies, including root differ #627
    • Test against php 7.4 #625
    Changelog

    Sourced from infection/infection's changelog.

    0.13.0

    Full Changelog (2019-05-18)

    Added:

    • Log the InitialTestsRun command line when --debug is used #520
    • Preliminary support for PCOV #667
    • Adding Line Numbers To Mutator Ignore List #663
    • Family bc*-functions mutators (bcmath support) #658
    • Family mb_*-functions mutators #654
    • Add a new unwrap mutator: ucwords #644
    • New @​unwrap mutator: lcfirst() #642
    • Provide compact output for CI environments #613
    • add unwrap array_pad mutator #680
    • add unwrap array_intersect_assoc mutator #679
    • #597 Array item removal mutator #649
    • Enhancement: Implement UnwrapTrim mutator #638
    • Enhancement: Implement UnwrapArrayUintersect mutator #637
    • Enhancement: Implement UnwrapArrayUintersectUassoc mutator #633
    • Enhancement: Implement UnwrapArrayUintersectAssoc mutator #628
    • Enhancement: Implement UnwrapArrayUdiff mutator #624
    • Mutator: AssignCoalesce. Upgrade PHPParser to 4.2.1 #641
    • Mutator: UnwrapUcFirst (unwrap the first argument of ucfirst() function) #635

    Fixed:

    • Multi line arrays are not properly handled by code coverage #652
    • Error when parsing method that creates anonymous class #616
    • Infection gets stuck in the first execution after configuration file is created #576
    • Wrong constructor ownership when returning an anonymous class #682
    • Do not mutate * to / and vice versa if one of the operands is numeric ±1.0 #673

    Changed:

    • Stop traversal of interfaces and abstract methods #656
    • Add a few more count esque functions to not decrement against #640
    • Enhancement: Normalize composer.json #629
    • Upgrade PHPUnit from ^6.5 to ^7.5 and all dependencies, including root differ #627
    • Test against php 7.4 #625

    0.12.0 (2019-01-24)

    Full Changelog

    BC Breaks:

    • Disabling mutating "true" -> "false" in TrueValue mutator for in_array/array_search #599
    ... (truncated)
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.

    Reviewed by dependabot-preview[bot] at 2019-05-20 04:54
Helps detect the user's browser and platform at the PHP level via the user agent

cbschuld/browser.php Helps detect the user's browser and platform at the PHP level via the user agent Installation You can add this library as a local

Jul 31, 2022
Rules to detect game engines and other technologies based on Steam depot file lists

SteamDB File Detection Rule Sets This is a set of scripts that are used by SteamDB to make educated guesses about the engine(s) & technology used to b

Aug 3, 2022
Mobile detect change theme and redirect based on device type. Magento 2 module.

Magento 2 Mobile Detect Theme Change Magento 2 Mobile detect system can be used to load different themes base on the client device (desktop, tablet, m

Jul 5, 2022
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Detect flaws in your architecture before they drag you down into the depths of dependency hell ... What it does System Requirements Installation Phive

Aug 4, 2022
Tool to detect assumptions

PHP Assumptions Setup $ composer require --dev rskuipers/php-assumptions Introduction PHP Assumptions is the result of a proof of concept inspired by

Jul 16, 2022
The main scope of this extension is to help phpstan to detect the type of object after the Assert\Assertion validation.

PHPStan beberlei/assert extension PHPStan beberlei/assert Description The main scope of this extension is to help phpstan to detect the type of object

Aug 2, 2022
Banana detect adblock :Detects ad blockers (AdBlock, ublock, ...)
Banana detect adblock :Detects ad blockers (AdBlock, ublock, ...)

banana detect adblock :Detects ad blockers (AdBlock, ublock, ...)

Aug 8, 2022
Detect the position of a face in an image.

Face Detector PHP GD 를 이용해 이미지의 얼굴 위치를 식별합니다. mauricesvay/php-facedetection 프로젝트를 기반으로 만들었습니다. js 로 포팅하며 개선한 사항들을 적용하여 error_reporting = E_ALL safe 하게

Jul 27, 2022
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

Nov 20, 2021
:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

sabre/vobject The VObject library allows you to easily parse and manipulate iCalendar and vCard objects using PHP. The goal of the VObject library is

Aug 10, 2022
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Jul 31, 2022
PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

Aug 1, 2022
PHP library providing retry functionality with multiple backoff strategies and jitter support

PHP Backoff Easily wrap your code with retry functionality. This library provides: 4 backoff strategies (plus the ability to use your own) Optional ji

Jun 25, 2022
Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host

Currency Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangera

Jul 4, 2022
A high-level machine learning and deep learning library for the PHP language.

Rubix ML A high-level machine learning and deep learning library for the PHP language. Developer-friendly API is delightful to use 40+ supervised and

Aug 15, 2022
PHP library to create and validate html forms

FormManager Note: this is the documentation of FormManager 6.x For v5.x version Click here Installation: This package requires PHP>=7.1 and is availab

Jul 4, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Jun 7, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Jun 7, 2022
This shell script and PHP file create a browseable HTML site from the Zig standard library source.
This shell script and PHP file create a browseable HTML site from the Zig standard library source.

Browseable Zig standard library This shell script and PHP file create a browseable HTML site from the Zig standard library source. The idea is to inve

Mar 20, 2022