thytanium/agent

This package is abandoned and no longer maintained. The author suggests using the jenssegers/agent package instead.

User-Agent class ported from CodeIgniter to Laravel

v2.0.1 2015-03-10 13:23 UTC

This package is not auto-updated.

Last update: 2019-08-12 20:12:40 UTC


README

For Laravel

User-Agent class ported from CodeIgniter to Laravel. It provides specific information about the user agents making requests to your app.

This project is based on CodeIgniter's User_Agent class.

Install

  1. Edit the require section in your composer.json file

    Laravel 4

    "require": {
    	"thytanium/agent": "1.*"
    }

    Laravel 5

    "require": {
    	"thytanium/agent": "2.*"
    }
  2. Run composer update

  3. Edit app/config/app.php

    'providers' => array(
    	...
    	'Thytanium\Agent\AgentServiceProvider',
    );
    
    ...
    
    'aliases' array(
    	...
    	'Agent' => 'Thytanium\Agent\Facades\Agent',
    );

Use

Browser

$browser = Agent::browser() //Firefox, Chrome, etc.

Browser version

$version = Agent::version() //35.0, 34.0, etc.

Platform

$platform = Agent::platform() //Windows 8, Windows XP, Linux, MacOS X

Mobile

$mobile = Agent::mobile() //iPhone, iPad, PlayStation 3, Android

Robot

$robot = Agent::robot() //Googlebot, Bing, Yahoo

Accepted languages

$languages = Agent::languages() //en-us, es-ar, en-gb

Accepted charsets

$charsets = Agent::charsets() //utf-8, iso-8859-1

Is it a browser?

$browser = Agent::isBrowser() //true or false

Is it a robot?

$robot = Agent::isRobot() //true or false

Is it a mobile?

$mobile = Agent::isMobile() //true or false

Is it a desktop?

$desktop = Agent::isDesktop() //true or false

Accepts language?

$language = Agent::acceptLanguage('en') //true or false

Accepts charset?

$charset = Agent::acceptCharset('utf-8') //true or false

Contributing

Feel free to contribute to this little project.

Links