Laravel detector mobile browser name version platform device robot crawler user language

Image for post
Image for post


How to implement:

composer require jenssegers/agent
Image for post
Image for post
Image for post
Image for post
'Agent' => Jenssegers\Agent\Facades\Agent::class,

How to use:

use Jenssegers\Agent\Agent;
$agent = new Agent();

Useful methods:

// Ubuntu, Windows, OS X, ...
// Chrome, IE, Safari, Firefox, ...
$browser = $agent->browser();
$version = $agent->version($browser);
$platform = $agent->platform();
$version = $agent->version($platform);
$agent->is('OS X');
// ['nl-nl', 'nl', 'en-us', 'en']
// iPhone, Nexus, AsusTablet, ...
// robot name

Blade view file usage:

@if ($agent->isMobile())

Show content for mobile ...


Global Blade view file usage:

php artisan make:provider AgentServiceProvider
namespace App\Providers;

use View;
use Jenssegers\Agent\Agent;
use Illuminate\Support\ServiceProvider;

class AgentServiceProvider extends ServiceProvider
public function boot()
$agent = new Agent();

View::share('agent', $agent);

public function register()
@if ($agent->isMobile())

Show content for mobile ...

Some other useful packages:

Previous Stories You will Love:

Written by

Web geek, Self-taught full-stack web developer, Learning Python, Laravel, Vuejs, UX/UI design, Nuclear Physicist PhD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store