PHPackages                             siment/module-http-header-theme-switch - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. siment/module-http-header-theme-switch

ActiveMagento2-module[HTTP &amp; Networking](/categories/http)

siment/module-http-header-theme-switch
======================================

Magento 2 module that enables automatic theme switching based on the X-UA-Device HTTP header. (Or any other header)

1.0.4(8y ago)81341[1 PRs](https://github.com/siment/magento2-http-header-theme-switch/pulls)AFL-3.0PHP

Since Aug 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/siment/magento2-http-header-theme-switch)[ Packagist](https://packagist.org/packages/siment/module-http-header-theme-switch)[ RSS](/packages/siment-module-http-header-theme-switch/feed)WikiDiscussions master Synced 2d ago

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

siment/module-http-header-theme-switch
======================================

[](#simentmodule-http-header-theme-switch)

Build status
------------

[](#build-status)

[![Build Status](https://camo.githubusercontent.com/3b7fbacd904a155e18c0119eff21086ecff4d765b57f6f57e6fa7566360c5705/68747470733a2f2f7472617669732d63692e6f72672f73696d656e742f6d6167656e746f322d687474702d6865616465722d7468656d652d7377697463682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/siment/magento2-http-header-theme-switch)[![Code Climate](https://camo.githubusercontent.com/9b7833a3996f8e90f7a8934b6932e525aa5916929db472854d67fda82246a73b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696d656e742f6d6167656e746f322d687474702d6865616465722d7468656d652d7377697463682f6261646765732f6770612e737667)](https://codeclimate.com/github/siment/magento2-http-header-theme-switch)[![Test Coverage](https://camo.githubusercontent.com/2d2391d80cf89580579dbf636f31d289a2e209a425b0777a10c7f83235aa38a5/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696d656e742f6d6167656e746f322d687474702d6865616465722d7468656d652d7377697463682f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/siment/magento2-http-header-theme-switch/coverage)[![Issue Count](https://camo.githubusercontent.com/5920fe9723b328212c61cabb000227848f827f655426bed622e9339a2f2fa238/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696d656e742f6d6167656e746f322d687474702d6865616465722d7468656d652d7377697463682f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/siment/magento2-http-header-theme-switch/issues)

Magento 2 module that enables automatic theme switching based on X-UA-Device header. (Or any other header)

What does this module do?
-------------------------

[](#what-does-this-module-do)

This module makes sure that Magento's [design exceptions](http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-apply.html#theme-apply-except)logic checks the value of the header "X-UA-Device" in addition to "User-Agent" when determining what theme it should use. You can also configure it to listen to other headers than the pre-configured "X-UA-Device" header.

Why this module?
----------------

[](#why-this-module)

### Short version

[](#short-version)

Because many web proxies, like [Varnish](https://varnish-cache.org), suggest to use the "X-UA-Device" header for [device detection](https://varnish-cache.org/docs/trunk/users-guide/devicedetection.html)and Magento should respect it.

### Longer version

[](#longer-version)

Magento 2 allows for theme switching based on [design exceptions](http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-apply.html#theme-apply-except)which enables "*you to specify an alternative theme for particular user-agents*".

There are hundreds of user agents out there now and it makes it challenging to correctly identify which agents are coming from mobile, tablet and desktop devices.

There are great libraries for making detection easier - like the generic [mobiledetect/mobiledetectlib](https://github.com/serbanghita/Mobile-Detect)and the excellent Magento module [eadesignro/module-mobiledetect](https://github.com/EaDesgin/magento2-mobiledetect). Those modules will not work out of the box if you have a web proxy like Varnish installed.

That is why I wanted to use the [Varnish Mobile Detect](https://github.com/willemk/varnish-mobiletranslate)module which sends the "X-UA-Device" header from Varnish for device detection rather than tampering with the "User-Agent" header.

How to install
--------------

[](#how-to-install)

In Magento root:

```
$ composer require siment/module-http-header-theme-switch:"~1.0"
$ php bin/magento module:enable Siment_HttpHeaderThemeSwitch
$ php bin/magento cache:clean
```

Configuration
-------------

[](#configuration)

In Magento admin:

**Stores** -&gt; (Settings) **Configuration** -&gt; **General** -&gt; **Design**-&gt; **HTTP Header Theme Switch** -&gt; **HTTP Header**:

HTTP header which will be matched for theme exceptions in addition to the standard header "User-Agent". Standard value is "*HTTP\_X\_UA\_DEVICE*"

You define the matching rules under **Content** -&gt; (Design) **Configuration**-&gt; (Select a theme) **Edit** -&gt; **User Agent Rules**

How to test
-----------

[](#how-to-test)

Make sure the Composer dependencies have been installed and that the "post-install-cmd" scripts have executed.

In module directory:

```
$ composer install
$ composer run-script post-install-cmd          # May not be necessary
$ vendor/bin/phpunit                            # For unit tests
$ vendor/bin/phpcs                              # For code sniffs
$ vendor/bin/phpmd src/,Test/ text phpmd.xml    # For mess detector
```

How to contribute
-----------------

[](#how-to-contribute)

Create an issue or a pull request.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](https://github.com/siment/magento2-http-header-theme-switch/blob/master/CHANGELOG.md)

License
-------

[](#license)

- Licensed under Academic Free License ("AFL") v. 3.0
- See [LICENSE.txt](https://raw.githubusercontent.com/siment/magento2-http-header-theme-switch/master/LICENSE.txt)or

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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 ~2 days

Total

5

Last Release

3175d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f61a7db5153c51838ebafdd4204f989619329c74c171e312a95817ac0950ba5d?d=identicon)[siment](/maintainers/siment)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/siment-module-http-header-theme-switch/health.svg)

```
[![Health](https://phpackages.com/badges/siment-module-http-header-theme-switch/health.svg)](https://phpackages.com/packages/siment-module-http-header-theme-switch)
```

###  Alternatives

[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.2M1](/packages/fastly-magento2)[yireo/magento2-linkpreload

Magento 2 extension to set HTTP Link headers for primary resources to allow for HTTP/2 preloading

92343.7k1](/packages/yireo-magento2-linkpreload)[developersalliance/module-table-rates

This module allows administrators to manage and view shipping table rates from the admin UI.

443.4k](/packages/developersalliance-module-table-rates)[mage-os/module-inventory-reservations-grid

Add a grid with the list of inventory reservations.

126.8k](/packages/mage-os-module-inventory-reservations-grid)[integer-net/magento2-async-varnish

Module for Magento 2 that defers and bundles purge requests to Varnish to reduce number of HTTP requests and increase speed of mass updates

221.3k](/packages/integer-net-magento2-async-varnish)

PHPackages © 2026

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