---
title: "Environment variables in Shopware 6 (aka process.env.XYZ)"
description: "With environement variabeles you can do a lot in Shopware 6. Especially when you use some build process to deploy your projects or test your plugins. So..."
url: "https://brocksi.net/blog/environment-variables-in-shopware-6-processenv/"
author: "Björn Meyer"
published: "2022-03-22"
lang: "en"
categories: ["Shopware 6"]
---

# Environment variables in Shopware 6 (aka process.env.XYZ)

With environement variabeles you can do a lot in Shopware 6. Especially when you use some build process to deploy your projects or test your plugins. So in this little post I will collect some of the important environment variables I found in Shopware 6. Maybe this will help you to find solutions for common problems. If I miss some variable that might be helpful pls leave a comment so I will update this post.

## **Project Root - Process ENV**

The PROJECT\_ROOT is set by the sh script you executing for example bin/build-administration.sh. Project root is set to the current folder of the project. Project root is also used to generate the ADMIN\_ROOT concatenate with /vendor/shopware/administration.

```
process.env.PROJECT_ROOT
```

## **App URL - Process ENV**

This is the main URL to the Storefront for example: APP\_URL=“[http://localhost:8080](http://localhost:8080/)” from file .env located in the root folder of your project.

```
process.env.APP_URL
```

## **Mode - Process ENV**

To use the hot reloading in Shopware 6 this variable need to be set to development or hot (see code below). If not it will always build the production build for the Adminstration. The mode is set in scripts part from package.json file and depends on which command you are using for example bin/build-administration.sh. If you wanna build with the hot reload function you should use one of this scripts: bin/watch-administration.sh or bin/watch-storefront.sh.

```
const isDev = process.env.mode === 'development'; // from Administration package.json
const isProd = process.env.mode !== 'development'; // from Administration package.json
const isHotMode = process.env.MODE === 'hot'; // from Storefront package.json
```

## **Shopware Admin build only Extensions - Process Env**

If you are an plugin developer and often need to rebuild the shopware administration then you can use this environement variable to only build the extensions. This will speed up the build process a lot.

```
process.env.SHOPWARE_ADMIN_BUILD_ONLY_EXTENSIONS
```

## **ElasticSearch - Process ENV’s**

Not every Shopware 6 feature is supported when you using ElasticSearch, also there are some Issues in special cases. So if you wanna disable ElasticSearch you should know that you need to set SHOPWARE\_ES\_ENABLED to 0 and SHOPWARE\_ES\_INDEXING\_ENABLED to 0. You set this in .env File and maybe restart your docker to get the ENV’s updated. Also you should reset the es:index with bin/console es:reset.

```
SHOPWARE_ES_HOSTS="elasticsearch:9200"
SHOPWARE_ES_ENABLED="0"
SHOPWARE_ES_INDEXING_ENABLED="0"
SHOPWARE_ES_INDEX_PREFIX="sw"
```

## **Transports: Async/Queued Messages - Process ENV**

Since Shopware Version 6.4.17.0 you can use the default Symfony Envoirment Variable to [controll async/queued Message target](https://symfony.com/doc/current/messenger.html#transports-async-queued-messages "controll async/queued Message target"). Uncomment whichever transport you want (or set it in your .env file).

```
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=doctrine://default
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
```

## **How to speed up admin build time, use less Memory and do not waste traffic?**

If you build the shopware admin you will realize that it is downloading always a chrome browser with ~145mb. This is really wasting time and network traffic. So you should set the PUPPETEER\_SKIP\_CHROMIUM\_DOWNLOAD variable to avoid this. Also when you got problems with Memory during admin build you can set this node option max-old-space-size, in my example below I allow 2000 MB to be used by node/npm during admin build. If you do not need the TYPECHECK for TypeScript you can skip this by setting DISABLE\_ADMIN\_COMPILATION\_TYPECHECK, this also speed up your build time.

```
export NODE_OPTIONS="--max-old-space-size=2000";
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true;
export DISABLE_ADMIN_COMPILATION_TYPECHECK=true;
```

## **Which file is generating the .env File if there is no one in root folder?**

You should look at this file: [vendor/shopware/recovery/Install/src/Service/EnvConfigWriter.php](https://github.com/shopware/platform/blob/trunk/src/Recovery/Install/src/Service/EnvConfigWriter.php#L54 "vendor/shopware/recovery/Install/src/Service/EnvConfigWriter.php") it is used during Install Command, Install App and Container Provider. So it is used in every important entry point.

## **Shopware 6.5: Changed Environment variables**

The goal was to unify names to the symfony defaults. So makre sure to adjust your setups.

- **MAILER\_URL** is now **MAILER\_DSN**
- **SHOPWARE\_ES\_HOSTS** is now **OPENSEARCH\_URL**

---

For sure I am missing some important environement variables 😉 pls tell me in the comments. Thx.
