Insight into the .env file

I often get questions, especially from tech savvy shop owners, how the shop can be set into dev mode and how to disable the http cache. And so I thought I write a post about a very central configuration file in Shopware, the .env file.

It is found at the root of the shop, and it could like this:







Let’s have a look at the respective variables:

The ‘INSTANCE_ID’ and ‘APP_SECRET’ fields are generally set on installation and should not be modified, they are e.g. used for communication with the Shopware Store.

Much more interesting is the ‘APP_ENV’ value. When set to ‘prod’, the shop is in production mode, for use in a regular reachable shop. When set to ‘dev’, a small bar appears at the bottom of the shop, the Symfony debug bar. It provides very detailed information about the current request. Be aware, that these information can be very revealing, so don’t use this in a shop which is reachable publicly.

The ‘DATABASE_URL’ holds information about the connection to the database. This is useful, if you want to set up a copy of the shop and need to provide another database, simply provide the new credentials in the url string. If your database is not hosted locally, you have to substitute localhost:3306 with the actual endpoint.

‘APP_URL’ is the link to your shop, where /admin is reachable. I saw some instances, where this value was empty, but that can lead to problems down the road, e.g. Shopware apps cannot communicate with the store.

‘SHOPWARE_HTTP_CACHE_ENABLED’ controls the http cache. When it is set to ‘0’ template files are getting loaded from source, which especially makes developing with twig files faster. In production this value always should be set to ‘1’, active.

This concludes this insight into Shopware’s .env file. But one extra tip: you can place a .env.local file in the shop root. This file overwrites the individuell values from the .env file. It comes in handy in an development environment.