Installing Hyvä through the CLI

Magento 2, Magento 2 local environment, Hyvä

I work a lot on Magento extensions, which need to work on multiple versions of Magento. For that kind of work, I tend to set up new Magento environments quite often. A while ago, I shared how you can set up Magento from a single command. Now that Hyvä has become more mainstream, I needed a way to install that too in a single command.


Please note: The next step requires to be executed in an environment where Magento 2 is already installed. I always install the sample data, but that is not a hard requirement. Next to that, you need Magerun installed on your system. I have named it magerun2, you might need to change it to whatever you have named it on your system.

The Command

This is the command I'm using:

composer config repositories.hyva-themes/magento2-theme-module git [email protected]:hyva-themes/magento2-theme-module.git && \
composer config repositories.hyva-themes/magento2-reset-theme git [email protected]:hyva-themes/magento2-reset-theme.git && \
composer config repositories.hyva-themes/magento2-email-module git [email protected]:hyva-themes/magento2-email-module.git && \
composer config repositories.hyva-themes/magento2-default-theme git [email protected]:hyva-themes/magento2-default-theme.git && \
composer config repositories.hyva-themes/magento2-compat-module-fallback git [email protected]:hyva-themes/magento2-compat-module-fallback.git && \
composer config repositories.hyva-themes/hyva-checkout git [email protected]:hyva-checkout/checkout.git && \
composer require hyva-themes/magento2-compat-module-fallback hyva-themes/magento2-default-theme hyva-themes/magento2-hyva-checkout && \
bin/magento setup:upgrade && \
magerun2 config:store:set design/theme/theme_id 3 --scope=default --scope-id=0 && \
magerun2 config:store:set design/theme/theme_id 5 --scope=stores --scope-id=1 && \
bin/magento config:set general/region/display_all 0 && \
bin/magento config:set hyva_themes_checkout/general/checkout default

Let's go over the steps:

composer config

Hyvä offers 2 ways to be installed: With a license through Composer or through direct access from GitLabe. I have the second, so I configure Composer so that it knows where to retrieve the packages.

composer require

This tells Composer to install:

  • The Hyvä theme (`hyva-themes/magento2-default-theme`)

  • The fallback theme, which I use often (`hyva-themes/magento2-compat-module-fallback`)

  • The Hyvä checkout (`hyva-themes/magento2-hyva-checkout`)


I don't think this needs an explanation. For those who do: This installs everything that is required in the database.

magerun2 config:store:set

This part took me the longest to figure out. This command is the same as going into your Magento backend to Content -> Design -> Configuration and then selecting the Hyvä theme.

config:set region

By default, the region is mandatory in the Hyvä checkout. As I live in the Netherlands, we don't have something like that and I find it annoying to always have to enter something manual there. That's why I'm disabling this.

config:set hyva_themes_checkout

This is to make sure the Hyvä Checkout is enabled when you try to place an order.


There is always room for improvement. One thing that I don't like in this setup is the fact that there are hard IDs used. For me, that's fine, as I always have the exact same install theme installed (Luma), but this can cause problems when you have more themes installed.

Want to respond?