Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 1.36 KB

File metadata and controls

40 lines (34 loc) · 1.36 KB

UserAgentParser

Build Status

User agent parser for Laravel.

Installation

Install via composer:

$ composer require zarei/user-agent-parser

Initialize in Laravel

  • Add the service provider to provider section in config/app.php:
Zarei\UserAgentParser\UserAgentServiceProvider::class,
  • Add the alias of User-Agent to aliases section in config/app.php:
'UserAgentParser' =>  \Zarei\UserAgentParser\Facades\UserAgentParser::class,

Usage

Parse any User-Agent:

$parsed = UserAgentParser::parse(request()->userAgent());

And attend to the table below for finding out how to access parsed data:

Entity Getter Properties Sample Result
Device $parsed->device() ->vendor
->model
->type
Xiaomi
Mi 5X
mobile
CPU $parsed->cpu() ->architecture arm
OS $parsed->os() ->name
->version
->major
Android
8.1.0
8
Browser $parsed->browser() ->name
->version
->major
Chrome
74.0.3729.169
74
Engine $parsed->engine() ->name
->version
->major
Webkit
604.3.5
604