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
It is found at the root of the shop, and it could like this:
APP_SECRET=f2a008d920fa6aa6ad624ae3c617af7dfba4f88a37b36e97af0483f69681fe46 INSTANCE_ID=519ee3e71bf3a32354f261a5a0dcc23d9f7ac834ad23e453710d442125741c76 APP_ENV=prod DATABASE_URL='mysql://DB_USER:DB_PASSWORD@localhost:3306/DB_NAME' APP_URL=https://myshopurl.com SHOPWARE_HTTP_CACHE_ENABLED='1'
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.