Mobile-Detect
CLAUDE.md11k starsChanged 3 years agoMITView on GitHub
Whenever you find a new rule that applies to this project, add it to this file. PHP library (Detection\MobileDetect) for detecting mobile devices/tablets via User-Agent strings and HTTP headers. Requires PHP >= 8.0. PSR-12 code style. Every time you run a performance review (ad-hoc benchmarking, before a release, after touching a hot path, or at the end of a perf-oriented PR), append a new dated section to PERFORMANCE.md using the template block at the bottom of that file. Do not…
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
Every time you run a performance review (ad-hoc benchmarking, before a release, after touching a hot path, or at the end of a perf-oriented …
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Whenever you find a new rule that applies to this project, add it to this file.
Project
PHP library (Detection\MobileDetect) for detecting mobile devices/tablets via User-Agent strings and HTTP headers. Requires PHP >= 8.0. PSR-12 code style.
Branch & Release
- Active branch:
4.x(rolling — one branch per major). Always rebase into4.x(notmainormaster). Tags follow<major>.<minor>.<patch>. - On new tag: update
@versiondocblock +$VERSIONproperty insrc/MobileDetect.php, andversioninMobileDetect.json.
Commands
# Tests
vendor/bin/phpunit -v -c tests/phpunit.xml
vendor/bin/phpunit -v -c tests/phpunit.xml --filter testMethodName
# Lint + static analysis
vendor/bin/phpcs
vendor/bin/php-cs-fixer fix
vendor/bin/phpstan analyse --memory-limit=1G --level 3 src tests
# Benchmark (defaults live in /phpbench.json and per-method @Revs/@Iterations)
composer bench # aggregate report
composer bench:baseline # stores tag=baseline + phpbench-baseline.xml
composer bench:compare # runs with --ref=baseline, enforces 2% @Assert
# Advisory CI: .github/workflows/4.x-bench.yml runs on every PR to 4.x,
# uploads artifacts, and posts a PR comment. Does not block merge.Performance reviews
Every time you run a performance review (ad-hoc benchmarking, before a release,
after touching a hot path, or at the end of a perf-oriented PR), append a new
dated section to PERFORMANCE.md using the template block at the bottom of
that file. Do not edit prior sections — they are a historical record for
regression comparison.
Minimum contents per section: branch/commit, PHP image, host, phpbench config, the full aggregate table (13 subjects today), and a short notes list interpreting what's surprising or actionable in the numbers.
Architecture
src/
MobileDetect.php # Core class: regex patterns, isMobile(), isTablet(), is(), version(), magic isXXXX() via __call
MobileDetectStandalone.php # Non-Composer wrapper (loads standalone/ autoloader)
Cache/Cache.php # In-memory PSR-16 cache with TTL
Exception/ # MobileDetectException + error codes
tests/
providers/vendors/*.php # UA fixture arrays per vendor (Apple, Samsung, etc.)
UserAgentTest.php # Data-driven tests from vendor fixtures
MobileDetectGeneralTest.php # Core logic tests
CacheTest.php, MobileDetectWithCacheTest.php, MobileDetectExceptionTest.php
Benchmark/MobileDetectBench.php # PHPBench suite (PSR-4: DetectionTests\Benchmark)Key Patterns
- Detection results are cached via PSR-16 (
CacheInterface). Default: in-memoryCache. Cache keys usesha1by default. $_SERVERHTTP headers auto-initialized unlessautoInitOfHttpHeadersconfig isfalse.- CloudFront headers (
HTTP_CLOUDFRONT_IS_MOBILE_VIEWER, etc.) are recognized for AWS detection. - Magic
isXXXX()calls dispatch through__call->is()->match()against static regex arrays ($phoneDevices,$tabletDevices,$operatingSystems,$browsers).
Trending
Less talk lately.about the whole repository
Who's talking about serbanghita/Mobile-Detect
- Stack Overflow“Detect mobile devices - and tablet devices”Stack Overflow · Apr 2, 2012 · 33 votes
- Stack Overflow“unable to access facebook app / fan page tab on mobile browser”Stack Overflow · Mar 18, 2014 · 22 votes
- Stack Overflow“Php mobile/tablet/desktop detect?”Stack Overflow · Jun 14, 2012 · 19 votes
- Stack Overflow“How to detect Ipad useragent on safari browser”Stack Overflow · Mar 2, 2020 · 10 votes
- Stack Overflow“redirect to mobile website using PHP”Stack Overflow · Sep 21, 2012 · 5 votes
The biggest 5 of 84 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 84
Talked about on GitHub, Stack Overflow and the web (84 times).
On GitHub · 50
- Sep 9, 2024Use Client Hints headers — foroco/php-browser-detection2 reactions
- May 23, 2024sinergi/browser-detector is abandoned since 2021, consider switching to mobiledetect instead? — mike-bronner/laravel-mixpanel2 reactions · 2 comments
- Oct 31, 2023mobiledetect/mobiledetectlib 2.8.42 requires php 5.6.* — laravel/jetstream2 reactions · 13 comments
- Nov 13, 2024[5.x] Supports PHP 8.4 — laravel/jetstream1 reaction
- Nov 2, 2023fix - package broken due to dependecy code change — jenssegers/agent1 reaction · 8 comments
45 more on GitHub
- Oct 8, 2026Bump mobiledetect/mobiledetectlib from 4.8.09 to 4.11.0 — Nagorik11/innoshop_dev0 reactions · 1 comment
- Aug 6, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — Rambo31/Cake-in-the-Sky0 reactions
- Jul 22, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — Incongo/imagenes_app0 reactions
- May 30, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — gauravsandhu1999/google-patent-assignment0 reactions
- May 30, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — angelxmoreno/reddit-buddy-dashboard0 reactions
- May 30, 2026Bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — Skuyer/my_app0 reactions
- May 29, 2026build(deps): bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — TS-NEXTOPT/kanban-cake0 reactions · 1 comment
- May 29, 2026chore(deps): bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — angelxmoreno/cakephp-api-tpl0 reactions · 1 comment
- May 28, 2026chore(deps): bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — trivo-ops/Cline_Bot0 reactions
- May 28, 2026build(deps): bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — GuimelAGS/cake_server_1.0.00 reactions · 1 comment
- May 28, 2026chore(deps): bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — MBacelar93/catalog-app0 reactions · 1 comment
- May 28, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — edpar87-cyber/Edgar-Fernandez0 reactions
- May 28, 2026Bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — Saiyukta/CMS0 reactions · 1 comment
- May 28, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — apps4web/dromus-bed0 reactions
- May 27, 2026Bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — DritBail/Proyecto_cake0 reactions · 1 comment
- May 27, 2026chore(deps): bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — angelxmoreno/beat-prompt-api0 reactions
- May 27, 2026Bump mobiledetect/mobiledetectlib from 4.10.0 to 4.11.0 — navneetyadav-code/free-qr-code-generator-api-php-mysql0 reactions
- May 27, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — Mazout-A/mercredi180 reactions
- May 25, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — SantiagoPilamunga/SistemaFinanciero_V2.50 reactions · 1 comment
- May 25, 2026Bump mobiledetect/mobiledetectlib from 4.8.01 to 4.11.0 — abelini/SPCRadioUAS0 reactions
- May 25, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.11.0 — khanh-SPN/webtest10 reactions
- May 7, 2026Future: use newer version of library mobile-detect — backdrop-contrib/mobile_detect0 reactions
- Apr 30, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.10.0 — PriyanshSharma80/CRUD-in-CakePHP50 reactions
- Apr 29, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.10.0 — Ioulianlc/CoursCakephp_POO0 reactions
- Apr 28, 2026build(deps): bump mobiledetect/mobiledetectlib from 4.8.10 to 4.10.0 — BorooBoss/cakephp5-app0 reactions
- Apr 25, 2026Update Mobile-Detect library to 4.10.0 version? — humhub/humhub0 reactions · 2 comments
- Apr 24, 2026Bump mobiledetect/mobiledetectlib from 4.8.10 to 4.10.0 — FernandezLau/freshblends0 reactions
- Feb 10, 2026chore(deps): bump mobiledetect/mobiledetectlib from 4.8.09 to 4.8.10 — rcmcphee/openemr_scan0 reactions · 1 comment
- Jan 14, 2026chore(deps): bump mobiledetect/mobiledetectlib from 4.8.09 to 4.8.10 — baestero/cep-api0 reactions · 1 comment
- Jan 13, 2026Bump mobiledetect/mobiledetectlib from 4.8.09 to 4.8.10 — aqimsyz/Farme-Grocery-Market-System0 reactions
- Oct 24, 2024Specifying headers and relying on $_SERVER — zenstruck/browser0 reactions · 1 comment
- Aug 30, 2024Upgrade Mobile Detect — epiphyt/block-control0 reactions · 1 comment
- Apr 20, 2024Bump mobiledetect/mobiledetectlib from 2.8.41 to 3.74.3 — jhowmael/cata-treco0 reactions
- Apr 11, 2024investigate replacement for matomo device detect — dotkernel/dot-user-agent-sniffer0 reactions
- Feb 4, 2024Next minor goal: Create an Action to run unit tests — serbanghita/gamedev0 reactions
- Dec 27, 2023Update mobiledetect/mobiledetectlib requirement from ^2.8 to ^3.74 — Huangjiancong12/JJcracker0 reactions
- Oct 30, 2023Bump mobiledetect/mobiledetectlib from 2.8.41 to 3.74.3 — jyukipann/property-management-system0 reactions
- Mar 9, 2023Update mobiledetect/mobiledetectlib requirement from ^2.8 to ^3.74 — 220ms/JJCrackers-Lavosh0 reactions
- Mar 6, 2023update Mobile detect to smth from 2.8.41 — hgoebl/mobile-detect.js0 reactions · 1 comment
- Dec 12, 2022Update mobiledetect/mobiledetectlib requirement from ^2.8 to ^3.74 — sq1235/cakephp0 reactions
- Dec 12, 2022Bump mobiledetect/mobiledetectlib from 2.8.39 to 3.74.0 — tofujlg/cakePHP_tutorial_cms0 reactions
- Dec 7, 2022Update mobiledetect/mobiledetectlib requirement from ^2.8 to ^2.8 || ^3.0 — magroski/frogg0 reactions
- Dec 5, 2022Bump mobiledetect/mobiledetectlib from 2.8.39 to 3.74.0 — jksolutions1/JKSolutions-Bookeep0 reactions
- Dec 5, 2022Update mobiledetect/mobiledetectlib requirement from ^2.8 to ^3.74 — elincocaine/cakephp0 reactions
- Dec 5, 2022Bump mobiledetect/mobiledetectlib from 2.8.39 to 3.74.0 — darrencjh/FIT30480 reactions
On Stack Overflow · 30
- Apr 2, 2012Detect mobile devices - and tablet devices33 votes
- Mar 18, 2014unable to access facebook app / fan page tab on mobile browser22 votes
- Jun 14, 2012Php mobile/tablet/desktop detect?19 votes
- Mar 2, 2020How to detect Ipad useragent on safari browser10 votes · 1 answer
- Sep 21, 2012redirect to mobile website using PHP5 votes
25 more on Stack Overflow
- Oct 26, 2017Up-to date and future proof way of detecting iOS in PHP (or Server side)4 votes · 2 answers
- Jul 30, 2016Check user open the site in App or not4 votes
- Jan 30, 2014Get Specific Device Information4 votes
- Dec 11, 2012PHP Responsive Conditional Includes4 votes
- Jul 3, 2019Twig - determine if mobile agent or not3 votes
- Sep 11, 2014simple redirection for mobile device using php3 votes
- Jun 3, 2014How to unset a function definition just like we unset a variable?3 votes
- Jun 2, 2017Determining the visitor's OS in PHP2 votes · 3 answers
- Jul 15, 2015How to determine if the device is Mobile or Desktop?2 votes · 4 answers
- Jun 6, 2014Pop-up message when site it accessed on mobile device2 votes
- May 27, 2013what is the best way to add mobile (or tablet...) detection within zf2?2 votes
- Dec 11, 2012PHP Responsive Conditional Includes2 votes · 3 answers
- Oct 3, 2022Wordpress - How to get device type and last login location with php1 vote
- Jun 6, 2020How detect user mobile information such as brand and model?1 vote
- Jul 27, 2016Check user open the site in App or not1 vote
- Nov 17, 2015Adding Useragent information to prewritten script1 vote
- Sep 29, 2015Loading different CSS for mobile phones (but not for tablets)1 vote
- Aug 13, 2015CodeIgniter mobile OS detection1 vote
- Jun 6, 2015JavaScript for Desktop or Mobile Detection1 vote
- Mar 22, 2015Mobile detect Innerhtml in php code functions.php1 vote · 1 answer
- Jul 17, 2014Separate phones from tablets (htaccess or javascript or php)1 vote
- Jun 5, 2014Which technique to hide right column with heavy content?1 vote
- Jan 10, 2014How to use .htaccess to show mobile site on phones but NOT tablets?1 vote
- Sep 30, 2013How can I "performance detect" browsers1 vote
- Jul 12, 2013Mobile Browser Check IF Statement1 vote
On the web · 4
- Aug 1, 2024[bug] · Issue #959 · serbanghita/Mobile-Detect — google.com
- Jan 5, 2024Tablet IOS detection · Issue #950 · serbanghita/Mobile-Detect — google.com
- Feb 4, 2023PHP/mobiledetect/mobiledetectlib/2.8.14 — google.com
- Jun 29, 2021Function check_mobile - General — google.com
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

