whatisgithub

What is mobile-detect?

serbanghita/mobile-detect — explained in plain English

Analysis updated 2026-06-24

10,682PHPAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

Mobile-Detect is a PHP library that tells your app whether the current visitor is on a mobile phone or tablet by reading browser headers, so you can serve different layouts or features per device.

Mindmap

mindmap
  root((mobile-detect))
    What it does
      Detect phone vs tablet
      Read User-Agent
      HTTP header parsing
    Versions
      v4 current PHP 8.2
      v3 LTS PHP 7.4
      v2 deprecated
    Use cases
      Redirect mobile users
      Skip heavy assets
      Adjust features
    Resources
      Gitbook docs
      Live demo site
      MIT license
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Redirect mobile visitors to a mobile-optimized layout or skip loading heavy assets on small screens.

USE CASE 2

Detect tablets separately from phones in a PHP app to apply different UI treatments for each device type.

USE CASE 3

Drop the library into a legacy PHP 7.4 environment using the long-term support v3 branch.

What is it built with?

PHP

How does it compare?

serbanghita/mobile-detectmockery/mockerytennc/webshell
Stars10,68210,72410,727
LanguagePHPPHPPHP
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Version 4 requires PHP 8.2 or higher, use v3 for PHP 7.4 environments.

MIT license, use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

Mobile-Detect is a PHP library that tells your web application whether the current visitor is using a mobile phone or tablet. It works by reading the User-Agent string, which is a short piece of text that every browser sends with each request to identify itself, and combining that with certain HTTP headers to figure out what kind of device is making the request. The use case is straightforward: if you want your PHP application to behave differently for mobile visitors, such as redirecting them to a mobile layout, skipping heavy assets, or adjusting features, you include this library and call its detection methods. The library is small and focused entirely on device detection rather than being a general-purpose browser utility. The library has three active version lines. Version 2 is deprecated and only supports older PHP releases. Version 3 is in long-term support mode for PHP 7.4 environments. Version 4 is the current recommended version and requires PHP 8.2 or higher. Each version lives on its own branch on GitHub. Users on modern PHP should use version 4. Documentation is hosted on Gitbook, and there is a live demo site where you can point a mobile browser to see what the library detects about your device. The project is open source under the MIT license and maintained by the original author, who accepts donations to cover hosting and development time.

Copy-paste prompts

Prompt 1
Using mobile-detect v4 in PHP 8.2, show me how to detect if the current visitor is on a mobile phone and redirect them to /mobile.
Prompt 2
How do I install mobile-detect and check in PHP whether a visitor is on a tablet versus a phone?
Prompt 3
I'm on PHP 7.4 and need device detection, which version of mobile-detect should I use and how do I install it?

Frequently asked questions

What is mobile-detect?

Mobile-Detect is a PHP library that tells your app whether the current visitor is on a mobile phone or tablet by reading browser headers, so you can serve different layouts or features per device.

What language is mobile-detect written in?

Mainly PHP. The stack also includes PHP.

What license does mobile-detect use?

MIT license, use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is mobile-detect to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is mobile-detect for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.