PHPackages                             elcommerce/magento2-app-emulation - 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. elcommerce/magento2-app-emulation

ActiveMagento2-module

elcommerce/magento2-app-emulation
=================================

A drop-in replacement for Magento App Emulation that supports nested environment emulation

1.0.0(today)00GPL-3.0-onlyPHPPHP &gt;=7.4

Since Aug 28Pushed todayCompare

[ Source](https://github.com/elcommerce/magento2-app-emulation)[ Packagist](https://packagist.org/packages/elcommerce/magento2-app-emulation)[ RSS](/packages/elcommerce-magento2-app-emulation/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Elcommerce Magento 2 App Emulation
==================================

[](#elcommerce-magento-2-app-emulation)

A drop-in replacement for `Magento\Store\Model\App\Emulation` that supports nested environment emulation.

Magento's standard implementation allows only one active emulation. If code that is already emulating a store calls another service that starts emulation, the inner call is ignored and its matching stop can restore the environment too early. This module keeps a stack of environment states so every start can be paired with a stop safely.

Features
--------

[](#features)

- Supports nested store-environment emulation.
- Restores the preceding environment when each nested call finishes.
- Preserves store, area, theme, locale, inline-translation state, and phrase renderer.
- Replaces the Magento service through dependency injection, so existing consumers do not need to change their injected class.
- Retains the public `startEnvironmentEmulation()` and `stopEnvironmentEmulation()` API.

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

[](#requirements)

- Magento 2 with `magento/module-store`
- PHP 7.4 or later

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

[](#installation)

Install the Composer package from a repository that provides it:

```
composer require elcommerce/magento2-app-emulation
bin/magento module:enable Elcommerce_AppEmulation
bin/magento setup:upgrade
bin/magento cache:clean
```

In production mode, regenerate dependency-injection code after installation:

```
bin/magento setup:di:compile
```

Confirm that the module is enabled:

```
bin/magento module:status Elcommerce_AppEmulation
```

Usage
-----

[](#usage)

Continue to inject Magento's standard emulation class. The module's DI preference supplies the nested-capable implementation automatically.

```
