Published on

Installing / Developing Shopware 6 with DDEV

Authors

This is a comprehensive, up-to-date guide to install and develop Shopware 6 locally with DDEV, including optional Elasticsearch and convenient watchers for the Storefront and Administration.

Note: This article consolidates and updates the original content. If your current page looks abbreviated, this version contains the missing sections from the source.

Guide History

  • updated in 02/2022 - upgraded all versions (Shopware 6.4, Elasticsearch 7.17), removed workarounds, added hint about APP_URL
  • updated in 07/2021 - added hint about mailer config in admin backend
  • updated in 03/2021 - added hint on resolving APP_URL message
  • updated in 10/2020 - based on Shopware 6.3, better DDEV port settings

Get started

This guide shows how to install Shopware 6 based on DDEV including Elasticsearch and file watchers.

Info — What’s DDEV? DDEV is an open source tool providing simple, cross-platform, Docker‑based local development setups for web/PHP projects. Learn more: https://ddev.com/ddev-local/

Basic Installation

First, clone the Shopware production template, configure DDEV, and install dependencies:

git clone --branch=6.4 https://github.com/shopware/production shopware
cd shopware
ddev config    # accept defaults (project type php, docroot public)
ddev start
ddev composer install

Warning If you plan to use the hot module reload/watchers for frontend development, do not use HTTPS for the watcher endpoints.

Resolve: Environment variable not found: "APP_URL" This may happen until https://issues.shopware.com/issues/NEXT-12476 is fixed. Create a .env file manually with:

APP_URL="https://shopware.ddev.site"

Then run the setup again with force:

ddev exec bin/console system:setup -f

Now let’s use the provided system setup to generate a basic .env file:

ddev exec bin/console system:setup

Application information
-----------------------
 Application environment [dev]:
  [0] prod
  [1] dev
 > dev

URL to your /public folder [http://shopware.ddev.site]:
 > public

Application information
-----------------------
 Blue Green Deployment (yes/no) [yes]:
 >

Generate keys and secrets
-------------------------

Database information
--------------------
 Database user [app]:
 > db
 Database password:
 >
 Database host [localhost]:
 > db
 Database port [3306]:
 >
 Database name [shopware]:
 > db
 Database SSL CA Path []:
 >
 Database SSL Cert Path []:
 >
 Database SSL Key Path []:
 >
 Skip verification of the database server's SSL certificate? (yes/no) [no]:
 > yes

Tip Display information about your DDEV environment (including database credentials) with:

ddev describe

To quickly install Shopware with a basic setup:

ddev exec bin/console system:install --create-database --basic-setup

Configure Mailhog in .env so Shopware can send mail locally:

MAILER_URL="smtp://localhost:1025?encryption=&auth_mode="

In the Shopware Administration go to Settings → System → Mailer and select “Use environment configuration”.

Ready — Launch with:

ddev launch

Adding Elasticsearch (optional)

Stop DDEV first:

ddev stop

Create .ddev/docker-compose.elasticsearch.yaml:

version: '3.6'

services:
  elasticsearch:
    image: elastic/elasticsearch:7.17.0
    environment:
      - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
      - discovery.type=single-node
    networks:
      default: {}
      ddev_default: {}

Update .env with elastic settings:

SHOPWARE_ES_HOSTS="elasticsearch:9200"
SHOPWARE_ES_ENABLED="1"
SHOPWARE_ES_INDEXING_ENABLED="1"
SHOPWARE_ES_INDEX_PREFIX="sw"

Start again:

ddev start

Verify from inside the container:

ddev ssh
./bin/console cache:clear
./bin/console es:index
curl -X GET elasticsearch:9200/_aliases

Example output:

{
  "sw_product_2fbb5fe2e29a4d70aa5854ce7ce3e20b_1595328482": { "aliases": {} },
  "sw_product_f3a34446aae24f5dbf689e32374b2c69_1595328482": { "aliases": {} }
}

Building and Watching Storefront/Administration (Frontend Development)

Build Storefront

Production build:

ddev exec bin/build-storefront.sh

Watch Storefront

When developing custom storefront themes, use the watcher instead of repeated builds. Requirements:

  • Run at least one build to ensure dependencies exist
  • Map the ports used by the watcher so they are reachable from the host

The watcher opens a webpack hot proxy and a Shopware proxy; map those ports by creating .ddev/docker-compose.shopware.yaml:

version: '3.6'

services:
  web:
    expose:
      - 9998
      - 9999
    environment:
      - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,9999:9999,9998:9998
      - HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILHOG_HTTPS_PORT}:8025,8899:9999,8888:9998

Restart DDEV and run:

ddev exec bin/watch-storefront.sh

Open http://shopware.ddev.site:9998

Note HTTP_EXPOSE/expose helps DDEV track ports per project and allows multiple projects to expose identical internal ports simultaneously.

Sometimes DDEV may add an additional APP_URL with https to .env. If that happens, change back to http to use the watcher.

Build Administration

ddev exec bin/build-administration.sh

Watch Administration

To run the Vue.js administration watcher inside the DDEV container, bind it to 0.0.0.0 and use a fixed port. Combine storefront and administration watcher settings in .ddev/docker-compose.shopware.yaml:

version: '3.6'

services:
  web:
    expose:
      # Storefront Hot Proxy Ports
      - 9997
      - 9998
      - 9999
    environment:
      # Shopware Administration Watch Host
      - HOST=0.0.0.0
      # Shopware Administration Watch Port
      - PORT=9997
      # Expose APP_URL to administration watcher
      - APP_URL=http://shopware.ddev.site
      - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,9999:9999,9998:9998,9997:9997
      - HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILHOG_HTTPS_PORT}:8025,8899:9999,8888:9998,8887:9997

Run the watcher:

ddev exec bin/watch-administration.sh

Open http://shopware.ddev.site:9997

That’s it — with this setup you have a complete Shopware 6 development environment based on DDEV.