2017 © Pedro Peláez
 

library agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

image

catcoder/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 237 Forks
  • 0 Open issues
  • 20 Versions
  • 0 % Grown

The README.md

Agent

Latest Stable Version Total Downloads Build Status Coverage Status Donate, (*1)

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobile Detect with desktop support and additional functionality., (*2)

, (*3)

Installation

Install using composer:, (*4)

composer require jenssegers/agent

Laravel (optional)

Add the service provider in app/config/app.php:, (*5)

'Jenssegers\Agent\AgentServiceProvider',

And add the Agent alias to app/config/app.php:, (*6)

'Agent' => 'Jenssegers\Agent\Facades\Agent',

Basic Usage

Start by creating an Agent instance (or use the Agent Facade if you are using Laravel):, (*7)

use Jenssegers\Agent\Agent;

$agent = new Agent();

If you want to parse user agents other than the current request in CLI scripts for example, you can use the setUserAgent and setHttpHeaders methods:, (*8)

$agent->setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2');
$agent->setHttpHeaders($headers);

All of the original Mobile Detect methods are still available, check out some original examples at https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples, (*9)

Is?

Check for a certain property in the user agent., (*10)

$agent->is('Windows');
$agent->is('Firefox');
$agent->is('iPhone');
$agent->is('OS X');

Magic is-method

Magic method that does the same as the previous is() method:, (*11)

$agent->isAndroidOS();
$agent->isNexus();
$agent->isSafari();

Mobile detection

Check for mobile device:, (*12)

$agent->isMobile();
$agent->isTablet();

Match user agent

Search the user agent with a regular expression:, (*13)

$agent->match('regexp');

Additional Functionality

Accept languages

Get the browser's accept languages. Example:, (*14)

$languages = $agent->languages();
// ['nl-nl', 'nl', 'en-us', 'en']

Device name

Get the device name, if mobile. (iPhone, Nexus, AsusTablet, ...), (*15)

$device = $agent->device();

Operating system name

Get the operating system. (Ubuntu, Windows, OS X, ...), (*16)

$agent = $agent->platform();

Browser name

Get the browser name. (Chrome, IE, Safari, Firefox, ...), (*17)

$browser = $agent->browser();

Desktop detection

Check if the user is using a desktop device., (*18)

$agent->isDesktop();

This checks if a user is not a mobile device, tablet or robot., (*19)

Phone detection

Check if the user is using a phone device., (*20)

$agent->isPhone();

Robot detection

Check if the user is a robot., (*21)

$agent->isRobot();

Robot name

Get the robot name. Note: this currently only works for major robots like Google, Facebook, Twitter, Bing, Baidu etc ..., (*22)

$robot = $agent->robot();

Browser/platform version

MobileDetect recently added a version method that can get the version number for components. To get the browser or platform version you can use:, (*23)

$browser = $agent->browser();
$version = $agent->version($browser);

$platform = $agent->platform();
$version = $agent->version($platform);

Note, the version method is still in beta, so it might not return the correct result., (*24)

License

Laravel User Agent is licensed under The MIT License (MIT)., (*25)

The Versions

10/08 2016

dev-master

9999999-dev https://github.com/catcoder/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent desktop agent

08/03 2016

v2.3.3

2.3.3.0 https://github.com/jenssegers/agent

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

02/03 2016

v2.3.2

2.3.2.0 https://github.com/jenssegers/agent

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

26/11 2015

v2.3.1

2.3.1.0 https://github.com/jenssegers/agent

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

17/10 2015

v2.3.0

2.3.0.0

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

16/10 2015

v2.2.2

2.2.2.0

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

28/08 2015

v2.2.1

2.2.1.0

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

15/08 2015

v2.2.0

2.2.0.0

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

15/05 2015

v2.1.7

2.1.7.0

A user agent class for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

26/02 2015

v2.1.6

2.1.6.0

A user agent class for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

22/01 2015

v2.1.5

2.1.5.0

A user agent class for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

07/12 2014

v2.1.4

2.1.4.0

A user agent class for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

23/09 2014

v2.1.3

2.1.3.0

A user agent class for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

14/08 2014

v2.1.2

2.1.2.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel platform browser user agent mobile useragent agent

09/06 2014

v2.1.1

2.1.1.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel platform browser user agent mobile useragent agent

03/05 2014

v2.1.0

2.1.0.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel platform browser user agent mobile useragent agent

27/04 2014

v2.0.2

2.0.2.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel platform browser user agent mobile useragent agent

16/01 2014

v2.0.1

2.0.1.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel platform browser user agent mobile useragent agent

02/12 2013

v2.0.0

2.0.0.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel platform browser user agent mobile useragent agent

30/11 2013

v1.0.0

1.0.0.0

A user agent class for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel platform browser user agent mobile useragent agent