A simple Laravel 4 service provider for including the Useragent for Laravel 4.
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
Update your packages with composer update or install with composer install.
To use the Useragent Service Provider, you must register the provider when bootstrapping your Laravel application. There are
essentially two ways to do this.
Find the providers key in app/config/app.php and register the Useragent Service Provider.
'providers' => array(
Find the aliases key in app/config/app.php.
'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.
$agent = Useragent::browser().' '. Useragent::version();
$agent = Useragent::robot();
$agent = Useragent::mobile();
$agent = 'Unidentified User Agent';
echo Useragent::platform(); // Platform info (Windows, Linux, Mac, etc.)
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
Note all method calls are static