PHPackages                             marcover9000/laravel-mobile-detect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. marcover9000/laravel-mobile-detect

ActiveLibrary[Templating &amp; Views](/categories/templating)

marcover9000/laravel-mobile-detect
==================================

Instant mobile detection access directly from within Blade templates.

v2.2.0(3w ago)11↓100%MITPHPPHP ^8.3

Since May 18Pushed 3w agoCompare

[ Source](https://github.com/marcover9000/laravel-mobile-detect)[ Packagist](https://packagist.org/packages/marcover9000/laravel-mobile-detect)[ RSS](/packages/marcover9000-laravel-mobile-detect/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (7)Used By (0)

Laravel Mobile Detect
=====================

[](#laravel-mobile-detect)

[![Latest Stable Version](https://camo.githubusercontent.com/80cfbca1ba3b86784f83f1d7c2a7c6c4537953cdf8982d3acc67efd2ab2a841a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6172636f766572393030302f6c61726176656c2d6d6f62696c652d6465746563742e737667)](https://packagist.org/packages/marcover9000/laravel-mobile-detect)[![Total Downloads](https://camo.githubusercontent.com/8c8024e94f5deaced4b54cbf0eae53449c1b1f3391e4840727f1f5148eb658b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6172636f766572393030302f6c61726176656c2d6d6f62696c652d6465746563742e737667)](https://packagist.org/packages/marcover9000/laravel-mobile-detect)[![PHP Version](https://camo.githubusercontent.com/c97f9d53f6cc2449fc436b370f965dbcde7c2eb8b3869f7c86ba9d12d0b3222b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6172636f766572393030302f6c61726176656c2d6d6f62696c652d6465746563742e737667)](https://packagist.org/packages/marcover9000/laravel-mobile-detect)[![License](https://camo.githubusercontent.com/af56cc41cd02606357bdab52fed5cb931e2f05058b47a809ff7e0115ac9c0ece/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6172636f766572393030302f6c61726176656c2d6d6f62696c652d6465746563742e737667)](https://packagist.org/packages/marcover9000/laravel-mobile-detect)

A package that enables you to use device detection right in your Blade templates. (Utilises the well-known, constantly updated [PHP mobile detection library](http://mobiledetect.net/).)

> Maintained fork for Laravel 12 by Marc (`marcover9000`). Original package by Barnabas Kecskes ([riverskies](https://github.com/riverskies/laravel-mobile-detect)), MIT licensed.

### When would you use this package?

[](#when-would-you-use-this-package)

Responsive CSS may help to make content in the browser look nice on different devices but it won't help you serve responsive content from your backend (at least not the easy way). This can have a really bad knock-on effect on the user experience (have you ever waited for a large image to load while having a bad connection on your mobile?). This package will make it a breeze to serve device-specific content right from your back-end.

### How does this package work?

[](#how-does-this-package-work)

The package implements various Blade directives that you can use to serve different content from your Blade template for different device types.

### Installation

[](#installation)

Install the package through Composer:

```
composer require marcover9000/laravel-mobile-detect
```

On Laravel 12 the service provider and the optional `MobileDetect` facade are auto-discovered — no manual registration needed.

> **NOTE** You might have to run `php artisan view:clear` for the Blade directives to take effect.

### Usage

[](#usage)

Use the new Blade directives in your template files:

```
@desktop

@elsedesktop

@enddesktop
```

> **NOTE** You might have to run `php artisan view:clear` to have the new Blade directives take effect!

### Available directives

[](#available-directives)

`@desktop`, `@elsedesktop`, `@enddesktop` - for destkop devices

`@handheld`, `@elsehandheld`, `@endhandheld` - for non-desktop (mobile and tablet) devices

`@tablet`, `@elsetablet`, `@endtablet` - for tablet devices

`@nottablet`, `@elsenottablet`, `@endnottablet` - for non-tablet (desktop or mobile) devices

`@mobile`, `@elsemobile`, `@endmobile` - for mobile devices

`@notmobile`, `@elsenotmobile`, `@endnotmobile` - for non-mobile (desktop or tablet) devices

`@ios`, `@elseios`, `@endios` - for iOS platforms

`@android`, `@elseandroid`, `@endandroid` - for Android platforms

`@device('Rule')`, `@elsedevice`, `@enddevice` - for any [mobiledetect rule](https://github.com/serbanghita/Mobile-Detect) (e.g. `@device('iPhone')`, `@device('AndroidOS')`, `@device('Chrome')`)

`@bot`, `@elsebot`, `@endbot` - for crawlers/bots

`@notbot`, `@elsenotbot`, `@endnotbot` - for non-bots

`@deviceclass` - echoes `mobile`, `tablet` or `desktop` (e.g. ``)

The usage of `@else...` directives are optional.

### Outside Blade

[](#outside-blade)

In controllers or middleware, use the facade (auto-discovered, no manual setup on Laravel 12) or the `device_type()` helper:

```
use Riverskies\Laravel\MobileDetect\Facades\MobileDetect;

if (MobileDetect::isMobile()) { /* ... */ }
MobileDetect::is('iOS');

device_type(); // 'mobile' | 'tablet' | 'desktop'
```

In a queued job or CLI context there is no request, so set the User-Agent explicitly (every directive, `device_type()` and `@deviceclass` then honour it):

```
MobileDetect::useAgent($userAgentCapturedFromTheRequest);
```

### Testing

[](#testing)

In your application's tests you can fake the detected device without mocking anything:

```
use Riverskies\Laravel\MobileDetect\Facades\MobileDetect;

MobileDetect::fake('mobile');   // also: 'tablet', 'desktop', 'bot'
MobileDetect::fake('iPhone');   // any mobiledetect rule, drives @device('iPhone')
```

The fake is scoped to the test (a fresh app per test); the presets `mobile`/`tablet`/`desktop`/`bot` drive the device-type and bot directives, a rule name drives `@device('Rule')`.

### Development

[](#development)

This package ships a Docker dev environment (PHP 8.3 + Composer):

```
docker compose build
docker compose run --rm dev composer install
docker compose run --rm dev vendor/bin/phpunit
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance95

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

22d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c1e19da153a1223e1402de124f52e975918c1f0b2b92f3ead63a98719c73915?d=identicon)[marcover9000](/maintainers/marcover9000)

---

Top Contributors

[![barnabaskecskes](https://avatars.githubusercontent.com/u/3535449?v=4)](https://github.com/barnabaskecskes "barnabaskecskes (23 commits)")[![marcover9000](https://avatars.githubusercontent.com/u/12560627?v=4)](https://github.com/marcover9000 "marcover9000 (19 commits)")[![EmilioBravo](https://avatars.githubusercontent.com/u/544288?v=4)](https://github.com/EmilioBravo "EmilioBravo (1 commits)")[![zyuzka](https://avatars.githubusercontent.com/u/12764988?v=4)](https://github.com/zyuzka "zyuzka (1 commits)")

---

Tags

blade-templatescomposer-packageslaravel-frameworklaravel12packagistlaravelblademobiledetection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marcover9000-laravel-mobile-detect/health.svg)

```
[![Health](https://phpackages.com/badges/marcover9000-laravel-mobile-detect/health.svg)](https://phpackages.com/packages/marcover9000-laravel-mobile-detect)
```

###  Alternatives

[riverskies/laravel-mobile-detect

Instant mobile detection access directly from within Blade templates.

2321.5M7](/packages/riverskies-laravel-mobile-detect)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k531.0k21](/packages/robsontenorio-mary)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5222.7k](/packages/hasinhayder-tyro-dashboard)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18379.7k9](/packages/technikermathe-blade-lucide-icons)[hasinhayder/tyro-login

Tyro Login - Beautiful, customizable authentication views for Laravel 12 &amp; 13

2443.7k5](/packages/hasinhayder-tyro-login)[ublabs/blade-simple-icons

A package to easily make use of Simple Icons in your Laravel Blade views.

1958.8k](/packages/ublabs-blade-simple-icons)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
