
Mobile Detect
A PHP class that tells whether a visitor's device is a phone or tablet.
- Stars
- 10.7k
- Forks
- 2.6k
- Licence
- MIT
- Language
- PHP
- Last update
- 15 days ago
- Type
- Library
What it is
Mobile Detect is a small PHP class that checks a website visitor's browser User-Agent string and certain HTTP headers to work out whether they are on a mobile device, including tablets. Developers use it to serve different layouts or redirect mobile users. The README describes it as lightweight and gives a demo site where you can test your own device.
- Redirect phone visitors to a mobile version of a page
- Serve a lighter layout or different content to tablets
- Log what kinds of devices visit a site
Great for
- PHP developers who need to tell mobile and tablet visitors apart on the server
- Sites that redirect mobile users to a separate mobile page or app
- Teams already using Composer and PHP 8.2 or newer
Not ideal for
- Projects that rely on CSS responsive design alone, since no server detection is needed there
- Non-PHP stacks, because this is a PHP class
- Anyone needing guaranteed accuracy, since detection relies on User-Agent strings which can be spoofed or incomplete
How to get it
- 1
Install with a package manager
You'll need: PHP 8.2 or newer (per README table for 4.x) · Composer
Clone the repository
git clone https://github.com/serbanghita/Mobile-Detect - 2
Run it
- Install the library into your project and include Composer's autoloader
- Create an instance of the Detection MobileDetect class
- Call its methods to check whether the current visitor is a mobile or tablet
- Test your results on the demo site at demo.mobiledetect.net
- 3
Get the most out of it
- Read the full documentation at docs.mobiledetect.net
- Check the demo site to see how your own device is detected
- Run the included PHPUnit test suite to verify behaviour in your environment
- Stay on the 4.x branch, which the README marks as current and recommended
Downloads
Strengths
- Small, focused library with a single purpose
- MIT licensed and actively maintained, with a recent push date in the metadata
- Full documentation hosted on Gitbook and a public demo site
Trade-offs
- Detection is based on User-Agent and headers, so results are not guaranteed
- Current version 4.x requires PHP 8.2 or newer, which may rule out older servers
- Older branches 2.x and 3.x are deprecated
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| Mobile-Detect (this) | 10.7k | Library | beginner | 15 days ago | PHP developers who need to tell mobile and tablet visitors apart on the server |
| symfony | 31.2k | Library | intermediate | 4 days ago | PHP developers building web applications that need a structured framework |
| image | 14.4k | Library | intermediate | 7 days ago | PHP developers who need to resize or convert uploaded images on a server |
| framework | 35k | Framework | intermediate | 4 days ago | PHP developers building web applications or APIs |
| bagisto | 28.3k | App | intermediate | 4 days ago | Developers building a custom online store on Laravel |
| guzzle | 23.4k | Library | intermediate | 11 days ago | PHP developers who need to call external REST or web service APIs |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.