Detect browsers and mobile devices in laravel

In this tutorial we will learn about detecting browsers and mobile deveices in laravel for this we will use newly built laravel package called HiSoRange Browser Detect package for Laravel 4-5.

his package is able to identify the visitors browser almost perfectly by useing multiple well tested packages and services together. The theory behind it is to use user-agent parser libraries together to get the most accurate result. The packages sets up a standard data schema and fills in the informations generated by plugins, if one of the plugin cannot determine an information like operating system version then there is a good chance the others could.

 

Features


  • Easily extend or personalize the analization flow.
  • Identify the browser’s family and it’s version.
  • Identify the operating system‘s software and it’s version.
  • Idenfity the browsing device‘s family and model.
  • Categorise devices such as mobile, tablet and desktop.
  • Determine the browser’s CSS protokol support as CSS1, CSS2, CSS3.
  • All semantic version is preparsed to major, minor and patch keys.
  • Out of the box caching, useing your app cache so you don’t need to set up anything.
  • Plugin oriented parsers, simple add, remove or manage plugins from the plugin config file.
  • Identify the the crawlers aka bots.
  • Import & export result into very compact strings which can be stored even in varchar fields.
  • NEW in 1.0.0 check support for JavaScript

Temporarily the UAParser plugin is turned off by default, will be readded as soon as I find time to force the composer to pull it down in a stable release.

 

So lets get started..

Installation

First add the package to your composer:

{
    "require": {
        "hisorange/browser-detect": "2.*" // For laravel 5.* versions
        "hisorange/browser-detect": "1.*" // For laravel 4.* versions
    }
}

After the composer update/install add the service provider to your app.php:

'providers' => array(
    // ...
    'hisorangeBrowserDetectProviderBrowserDetectService',
    // ...
)

Add the alias to the aliases in your app.php:

'aliases' => array(
    // ...
    'BrowserDetect' => 'hisorangeBrowserDetectFacadeParser',
)

You must use personal configurations, just publish the package’s configuration files, (plugins.php also published with this)

php artisan vendor:publish

Finaly, enjoy

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

  • shalini

    Hey,

    Why i am getting “HiSoRange Generic OS” as an OSName?

    • Shiro

      It is set in the config.php , you can change it.

  • Shiro

    This package seem like not supported for Laravel 5.4 / 5.5, and the repo owner did not maintenance it. There is a lot issue haven’t fixed. Try alternative package will be better

Pin It on Pinterest

Shares