A package that can detect mobile or desktop user in Laravel

Still troubled with how to detect mobile device or desktop device?

Patrick Wan
3 min readApr 26, 2022

Sometimes we might think about how do we control our web view in mobile or tablet. Today I gonna should you a package that can let us easy to manage it, it will help us more it our development if you are doing desktop and mobile view.

The package I gonna introduce is jenssegers/agent. A PHP desktop/mobile user agent parser with support for Laravel, based on Mobile Detect with desktop support and additional functionality.

This package can install it via composer with a simple command:

composer require jenssegers/agent

After the installation you might have an option in Laravel which you can add the service provider in your config or not. If yes, please follow the following below:

Add the Service Provider in config/app.php:

Jenssegers\Agent\AgentServiceProvider::class,

And add the Agent Alias to config/app.php:

'Agent' => Jenssegers\Agent\Facades\Agent::class,

--

--

Patrick Wan

My name’s Patrick. I’m a Software Developer, experience in Laravel, Vue Js, React Js, Livewire, Jquery, Codegniter, NPM, GIT. I have 5 years plus experience.