PHPackages                             hryvinskyi/magento2-store-matcher - 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. hryvinskyi/magento2-store-matcher

ActiveLibrary

hryvinskyi/magento2-store-matcher
=================================

Automatic store/website code matcher for multi-store Magento 2 setup based on HTTP\_HOST

1.0.0(5mo ago)172↓50%1MITPHPPHP &gt;=8.1

Since Nov 19Pushed 5mo agoCompare

[ Source](https://github.com/hryvinskyi/magento2-store-matcher)[ Packagist](https://packagist.org/packages/hryvinskyi/magento2-store-matcher)[ RSS](/packages/hryvinskyi-magento2-store-matcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Magento 2 / Adobe Commerce Store/Website Matcher
================================================

[](#magento-2--adobe-commerce-storewebsite-matcher)

Automatic store/website code matcher for multi-store Magento 2 / Adobe Commerce setups based on HTTP\_HOST.

[![Latest Stable Version](https://camo.githubusercontent.com/c4fb58cbc6622f415920465fc0b32acbc0e1fc81e8d85ebb2ceb27872ff0af00/68747470733a2f2f706f7365722e707567782e6f72672f68727976696e736b79692f6d6167656e746f322d73746f72652d6d6174636865722f762f737461626c65)](https://packagist.org/packages/hryvinskyi/magento2-store-matcher)[![Total Downloads](https://camo.githubusercontent.com/a39c3099023ff1a6c84696107e19c587fe5be5b5db24e9410599d5a11ed8ad03/68747470733a2f2f706f7365722e707567782e6f72672f68727976696e736b79692f6d6167656e746f322d73746f72652d6d6174636865722f646f776e6c6f616473)](https://packagist.org/packages/hryvinskyi/magento2-store-matcher)[![PayPal donate button](https://camo.githubusercontent.com/0d6e4d8b50b5983a58205941b1a581b1305903393b7a39da574e3f60af3c7f5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d79656c6c6f772e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=volodymyr%40hryvinskyi%2ecom&lc=UA&item_name=Magento%202%20%2F%20Adobe%20Commerce%20Store%2FWebsite%20Matcher&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using Paypal")[![Latest Unstable Version](https://camo.githubusercontent.com/f2c707737a3098fcf6c28f5b9f9946ee2768f187ecb233562a22d9476ad0f850/68747470733a2f2f706f7365722e707567782e6f72672f68727976696e736b79692f6d6167656e746f322d73746f72652d6d6174636865722f762f756e737461626c65)](https://packagist.org/packages/oakcms/oakcms)[![License](https://camo.githubusercontent.com/254f6e63efaf4e098d77f1370736d8a3209c7c298ccdd238ec7542582489d540/68747470733a2f2f706f7365722e707567782e6f72672f68727976696e736b79692f6d6167656e746f322d73746f72652d6d6174636865722f6c6963656e7365)](https://packagist.org/packages/hryvinskyi/magento2-store-matcher)

Overview
--------

[](#overview)

This Composer package automatically sets the correct Magento store or website code based on the incoming HTTP\_HOST header, eliminating the need to manually configure store matching in `pub/index.php`.

Features
--------

[](#features)

- **Zero configuration** - Works automatically after installation
- **Performance optimized** - Stores/Websites can be cached by opcache (static array in app/etc/store-hosts.php)
- **Local overrides** - Support for environment-specific configuration
- **Composer autoload** - Uses standard Composer autoload mechanism

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

[](#installation)

1. Run the following Composer command in your Magento 2 / Adobe Commerce project root:

```
composer require hryvinskyi/magento2-store-matcher
```

The post-install script will automatically create `app/etc/store-hosts.php` and `app/etc/store-hosts.local.php` if they don't exist.

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

[](#configuration)

### Main Configuration

[](#main-configuration)

Edit `app/etc/store-hosts.php` to define your store and website host mappings:

```
return [
    'store' => [
        'default' => ['www.example.com', 'example.com'],
        'french' => ['fr.example.com', 'french.example.com'],
        'german' => ['de.example.com', 'german.example.com'],
        // ... more stores
    ],
    'website' => [
        'base' => ['www.example.com'],
        'europe' => ['eu.example.com'],
        // ... more websites
    ],
];
```

### Local Overrides

[](#local-overrides)

For environment-specific configuration, create `app/etc/store-hosts.local.php`:

```
return [
    'store' => [
        'default' => ['test.example.test', 'localhost'],
        'en_store' => ['en.example.test'],
    ],
];
```

This file will be automatically merged with the main configuration and can be gitignored.

How It Works
------------

[](#how-it-works)

1. Composer's autoload mechanism loads `src/autoload.php` on every request
2. The autoload file checks if running in web context (not CLI)
3. It calls `StoreMatcher::match()` which contains all the matching logic
4. The matcher loads configuration from `app/etc/store-hosts.php`
5. It modifies `$_SERVER` with `PARAM_RUN_TYPE` and `PARAM_RUN_CODE`
6. Magento bootstrap uses these values to determine the store/website

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Magento 2.4+

License
-------

[](#license)

MIT

Author
------

[](#author)

Volodymyr Hryvinskyi

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance70

Regular maintenance activity

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

174d ago

### Community

Maintainers

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

---

Top Contributors

[![hryvinskyi](https://avatars.githubusercontent.com/u/9294098?v=4)](https://github.com/hryvinskyi "hryvinskyi (3 commits)")

### Embed Badge

![Health badge](/badges/hryvinskyi-magento2-store-matcher/health.svg)

```
[![Health](https://phpackages.com/badges/hryvinskyi-magento2-store-matcher/health.svg)](https://phpackages.com/packages/hryvinskyi-magento2-store-matcher)
```

PHPackages © 2026

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