Jens Segers on Oct 17 2015

Getting device information from your visitors

Mobiledetect is awesome, but it doesn't extract information for desktop devices and browser. So I decided to create my own package that extends Mobiledetect; meet the Agent.


Agent parses the User-Agent header that your browser sends along with all HTTP requests. It uses a list of patterns to detect what browser and devices you are using. For example, my browser it would return the following information:

Browser: Safari 9.0
Platform: OS X 10.11
Device: Macintosh
Mobile: no
Tablet: no
Desktop: yes
Bot: no

To get started, simply install the package using composer:

composer require jenssegers/agent

And create an Agent instance:

use Jenssegers\Agent\Agent;

$agent = new Agent;
$browser = $agent->browser();
$platform = $agent->platform();

For more information about the available methods, check out the project on github.


Ahmad Saleem 2 months ago

good job