Git Product home page Git Product logo

phpuseragent's Introduction

PHP User Agent Parser

Latest Stable Version Total Downloads Latest Unstable Version License Build Status HHVM Status Scrutinizer Code Quality

What It Is

A simple, streamlined PHP user-agent parser!

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

Why Use This

You have your choice in user-agent parsers. This one detects all modern browsers in a very light, quick, understandable fashion. It is less than 200 lines of code, and consists of just three regular expressions! It can also correctly identify exotic versions of IE others fail on.

It offers 100% unit test coverage, is installable via Composer, and is very easy to use.

What It Does Not Do

OS Versions

User-agent strings are not a reliable source of OS Version!

  • Many agents simply don't send the information.
  • Others provide varying levels of accuracy.
  • Parsing Windows versions alone almost nearly doubles the size of the code.

I'm much more interested in keeping this thing tiny and accurate than adding niché features and would rather focus on things that can be done well.

All that said, there is the start of a branch to do it I created for a client if you want to poke it, I update it from time to time, but frankly if you need to reliably detect OS Version, using user-agent isn't the way to do it. I'd go with JavaScript.

Requirements

  • PHP 5.3.0+

Installing

PHP User Agent is available through Packagist via Composer.

{
	"require": {
		"donatj/phpuseragentparser": "*"
	}
}

Sample Usage

$ua_info = parse_user_agent();
/*
array(
	'platform' => '[Detected Platform]',
	'browser'  => '[Detected Browser]',
	'version'  => '[Detected Browser Version]',
);
*/

Currently Detected Platforms

  • Desktop
    • Windows
    • Linux
    • Macintosh
    • Chrome OS
  • Mobile
    • Android
    • iPhone
    • iPad
    • Windows Phone OS
    • Kindle
    • Kindle Fire
    • BlackBerry
    • Playbook
    • Tizen
  • Console
    • Nintendo 3DS
    • New Nintendo 3DS
    • Nintendo Wii
    • Nintendo WiiU
    • PlayStation 3
    • PlayStation 4
    • PlayStation Vita
    • Xbox 360
    • Xbox One

Currently Detected Browsers

  • Android Browser
  • BlackBerry Browser
  • Camino
  • Kindle / Silk
  • Firefox / Iceweasel
  • Safari
  • Internet Explorer
  • IEMobile
  • Chrome
  • Opera
  • Midori
  • Vivaldi
  • TizenBrowser
  • Lynx
  • Wget
  • Curl

More information is available at Donat Studios.

phpuseragent's People

Contributors

donatj avatar simsimy avatar dacorp avatar atomantic avatar bitdeli-chef avatar manavo avatar toolstack avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.