PHPackages                             vxm/laravel-mobile-first - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. vxm/laravel-mobile-first

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vxm/laravel-mobile-first
========================

Support implement mobile-first principle for your Laravel application.

1.0.1(6y ago)9482[2 issues](https://github.com/vuongxuongminh/laravel-mobile-first/issues)[1 PRs](https://github.com/vuongxuongminh/laravel-mobile-first/pulls)MITPHPPHP ^7.1

Since Jun 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/vuongxuongminh/laravel-mobile-first)[ Packagist](https://packagist.org/packages/vxm/laravel-mobile-first)[ Docs](https://github.com/vuongxuongminh/laravel-mobile-first)[ RSS](/packages/vxm-laravel-mobile-first/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

 [ ![](https://avatars0.githubusercontent.com/u/958072) ](https://github.com/laravel)

Laravel Mobile First
====================

[](#laravel-mobile-first)

 [![Latest version](https://camo.githubusercontent.com/46ffa64a05bf5aa88a0dc6c9de5f6884e1432bae1f92878748ea0e1297f54aca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76786d2f6c61726176656c2d6d6f62696c652d66697273742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vxm/laravel-mobile-first) [![Build status](https://camo.githubusercontent.com/0fc1bf428749590381dad291690c02ae62f558f237f7c6440c2078bf7565fc99/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f76756f6e6778756f6e676d696e682f6c61726176656c2d6d6f62696c652d66697273742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/vuongxuongminh/laravel-mobile-first) [![Quantity score](https://camo.githubusercontent.com/0c1fa66da32bcc28bfa02d44594604dce147cf3c7286dafeacffc83fea9001b8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f76756f6e6778756f6e676d696e682f6c61726176656c2d6d6f62696c652d66697273742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vuongxuongminh/laravel-mobile-first) [![StyleCI](https://camo.githubusercontent.com/a41cf9baac0c5d787beefb7b6528ff35b72e3a26402454857a17aa5cc3fbe0c5/68747470733a2f2f7374796c6563692e696f2f7265706f732f3139323133383635312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/192138651) [![Total download](https://camo.githubusercontent.com/ed2d2cd81ae883473ad5c0ccea06def808aeec0c1e46c3537adf4c3c6e296c08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76786d2f6c61726176656c2d6d6f62696c652d66697273742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vxm/laravel-mobile-first) [![License](https://camo.githubusercontent.com/77e80ed5ed4ab7c593afee7738ca400b6749ea2809e97956a385bf3fe9d46de3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f76786d2f6c61726176656c2d6d6f62696c652d66697273742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vxm/laravel-mobile-first)

About it
--------

[](#about-it)

A package support you implementing mobile-first principle base on [Jenssegers Agent](https://github.com/jenssegers/agent).

Installation
------------

[](#installation)

Require Laravel Mobile First using [Composer](https://getcomposer.org):

```
composer require vxm/laravel-mobile-first
```

After require, you need to publish the config-file with:

```
php artisan vendor:publish --provider="VXM\MobileFirst\MobileFirstServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [
    /**
     * Your mobile site use to redirect when user not using desktop device.
     * Note: it only affect when you registered `VXM\MobileFirst\MobileRedirect` middleware.
     */
    'mobile_url' => 'https://m.yoursite.com',

    /**
     * Keep url path when redirect to mobile url (ex: https://yoursite.com/abc to https://m.yoursite.com/abc).
     */
    'keep_url_path' => true,

    /**
     * HTTP status code will be set when redirect to mobile url.
     */
    'redirect_status_code' => 301,

    /**
     * HTTP request method should be redirect to mobile url.
     */
    'redirect_methods' => ['OPTIONS', 'GET'],

    /**
     * Enable auto switch view by device type.
     * When enabled, the system auto switch view to compatible view (sub-view) by user device type (ex: 'index.blade.php' => 'mobile/index.blade.php'),
     * compatible view will be find on `device_sub_dirs`. If not found, not affect.
     */
    'auto_switch_view_by_device' => false,

    /**
     * An array with key is device type and value is sub dir of it. Use to switch view to compatible view (sub-view) by user device type.
     */
    'device_sub_dirs' => [
        //'phone' => 'phone', // switch when device is phone.
        //'tablet' => 'tablet', // switch when device is tablet.
        //'android' => 'android', // switch when device os is android.
        //'ios' => 'ios', // switch when device os is ios.
        'mobile' => 'mobile', // switch when device is tablet or phone.
    ],
];
```

Usage
-----

[](#usage)

This package provides you two features:

- [Redirect end-user to mobile site url if they not using desktop device.](#mobile-redirect)
- [Auto switch view to compatible view (sub-view)](#auto-switch-view)

### Mobile redirect

[](#mobile-redirect)

You need setup your mobile site url in your `mobilefirst` config file:

```
    'mobile_url' => 'https://m.yoursite.com',
```

Now add middleware:

```
// app/Http/Kernel.php

protected $middleware = [
       ...
       \VXM\MobileFirst\MobileRedirect::class,
],
```

### Auto switch view

[](#auto-switch-view)

This feature is disabled by default, you need to enabled it in `mobilefirst` config file:

```
    'auto_switch_view_by_device' => true,
```

It is a way to replace a set of views with another by user device without the need of touching the original view rendering code. You can use it to systematically change the look and feel of an application depend on user device. For example, when call `view('about')`, you will be rendering the view file `resources/views/about.blade.php`, if user use mobile device, the view file `resources/views/mobile/about.blade.php` will be rendered, instead.

The `device_sub_dirs` governs how view files should be replaced by user device. It takes an array of key-value pairs, where the keys are the device types and the values are the corresponding view sub-directory. The replacement is based on user device: if user device match with any key in the `device_sub_dirs` array, a view path will be added with the corresponding sub-directory value. Using the above configuration example, when user using mobile device because it match the key mobile, a view path will be added mobile look like `resources/views/mobile/about.blade.php`. Of course you can change the value or add more cases:

```
    'device_sub_dirs' => [
        'ios' => 'apple', // switch when device os is ios.
        'mobile' => 'mobile', // switch when device is tablet or phone.
    ],
```

The above configuration if user using ios, the view path will be added `apple`.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~12 days

Total

2

Last Release

2507d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8901d64a1059726b851dbdd91463ad1d3169f9dba6a2dcff11d05f97d9bccaea?d=identicon)[vuongxuongminh](/maintainers/vuongxuongminh)

---

Top Contributors

[![vuongxuongminh](https://avatars.githubusercontent.com/u/38932626?v=4)](https://github.com/vuongxuongminh "vuongxuongminh (21 commits)")

---

Tags

laravel-packagemobile-firstvxmlaravel-mobile-first

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vxm-laravel-mobile-first/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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