2017 © Pedro Peláez
 

library useragent

Useragent Package for Laravel 4

image

mews/useragent

Useragent Package for Laravel 4

  • Wednesday, December 31, 2014
  • by mewebstudio
  • Repository
  • 6 Watchers
  • 13 Stars
  • 6,112 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Useragent for Laravel 4

A simple Laravel 4 service provider for including the Useragent for Laravel 4., (*1)

Installation

The Useragent Service Provider can be installed via Composer by requiring the mews/useragent package and setting the minimum-stability to dev (required for Laravel 4) in your project's composer.json., (*2)

{
    "require": {
        "laravel/framework": "4.0.*",
        "mews/useragent": "dev-master"
    },
    "minimum-stability": "dev"
}

Update your packages with composer update or install with composer install., (*3)

Usage

To use the Useragent Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this., (*4)

Find the providers key in app/config/app.php and register the Useragent Service Provider., (*5)

    'providers' => array(
        // ...
        'Mews\Useragent\UseragentServiceProvider',
    )

Find the aliases key in app/config/app.php., (*6)

    'aliases' => array(
        // ...
        'Useragent' => 'Mews\Useragent\Facades\Useragent',
    )

This example attempts to determine whether the user agent browsing your site is a web browser, a mobile device, or a robot. It will also gather the platform information if it is available., (*7)

if (Useragent::is_browser())
{
    $agent = Useragent::browser().' '. Useragent::version();
}
elseif (Useragent::is_robot())
{
    $agent = Useragent::robot();
}
elseif (Useragent::is_mobile())
{
    $agent = Useragent::mobile();
}
else
{
    $agent = 'Unidentified User Agent';
}

echo $agent;

echo Useragent::platform(); // Platform info (Windows, Linux, Mac, etc.)

Method Reference

All methods in the Agent class are the same as the methods in the Codeigniter user agent library. You can read the documentation http://codeigniter.com/user_guide, (*8)

Note all method calls are static Eg, (*9)

Useragent::is_browser(); 

The Versions

31/12 2014

dev-master

9999999-dev http://github.com/mewebstudio/Useragent

Useragent Package for Laravel 4

  Sources   Download

LGPL

The Requires

 

laravel laravel 4 useragent l4 agent