Add support for multi-storefront Magento #869
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I really want to know if the method described under
How multi-storefront switching works
is the standard way of switching between storefronts, or if it's just a technique peculiar to my workplace.This may be going too far towards how one hosting solution (Adobe's Magento Cloud service) sets things up; other hosting solutions are available.
My change
(Aside from a slight refactor to make it easier) this change adds an additional YAML file,
compose.multi-storefront.yaml
, that adds 2 additional volumes toapp
andphpfpm
:src
->/app
- this mimics the directory layout when deployed to Magento Cloud.src/php.ini
->/usr/local/etc/php/conf.d/local-php.ini
- mapped so that PHP will load it.It only uses
compose.multi-storefront.yaml
if bothsrc/php.ini
andsrc/magento-vars.php
exist.How multi-storefront switching works
Multi-storefront switching is performed by modifying the
$_SERVER['MAGE_RUN_CODE']
and$_SERVER['MAGE_RUN_TYPE']
values inside of$_SERVER
. It's done in a special file calledmagento-vars.php
. Here's an example:This file is included in every request via
src/php.ini
:Using our same example domains, getting this setup for local development depends on modifications to
/etc/hosts
to make bothdefaultstore.example.dev
andstore1.example.dev
work in the browser:Running
bin/setup-ssl defaultstore.example.dev store1.example.dev
is not a bad idea either.