Using ddev for Shopware 6 Local Development

ddev is a light-weight, open-source tool for local PHP development environments. It is very easy, if not intuitive, to use, installation is simple and hassle-free (at least on my Ubuntu machine). Also, ddev integrates neatly with CI/CD, as all project specific stuff for ddev just goes into one folder. ddev supports xdebug and is perfect to work with phpstorm.

Read here on how to set up a local Shopware 6 enviroment with ddev in just 5 minutes.

Five Minute Setup Guide___STEADY_PAYWALL___

These instructions assume that you have setup docker and ddev on your machine, as laid out here: https://ddev.readthedocs.io/en/stable/

There is also a quick guide on ddev docs: https://ddev.readthedocs.io/en/stable/users/cli-usage/#shopware-6-quickstart

This is the way I setup a project for my new clients:

  • Create a project folder and cd into it
  • Download Shopware (you may want to replace the version to reflect the most current one) and unzip:
mkdir ~/myproject && cd ~/myproject
wget -O install_6.4.8.1.zip https://www.shopware.com/en/Download/redirect/version/sw6/file/install_6.4.8.1_0d8536adc1256503651ed5a60aef9c10ddfd03b0.zip
unzip install_6.4.8.1.zip
  • Create a folder .ddev inside your project folder
mkdir .ddev
  • Inside .ddev, create a file config.yaml and copy & paste the content below into it
name: myproject
type: shopware6
docroot: public
php_version: "8.0"
webserver_type: nginx-fpm
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
mariadb_version: ""
mysql_version: "8.0"
use_dns_when_possible: true
composer_version: ""
web_environment:
  - APP_URL=https://${DDEV_SITENAME}.ddev.site
  - COMPOSER_MEMORY_LIMIT=-1
omit_containers: [dba]

You may want to replace “myproject” with a project name of your choice.

  • From inside your project folder run the command ddev start. Since ddev will modify your /etc/hosts file to link the project url, you will need to have your admin password at hand.
cd ~/myproject && ddev start
  • ddev will start four containers: a web server, a database server, a router and an ssh agent. The web server also has an integrated mailhog server to facilitate development and testing of mail templates.
  • Once ddev has fully come up, you can reach Shopware’s web installer via your browser using the url https://myproject.ddev.site.
  • Now install Shopware following the installer docs.
  • During the install process, when asked for database credentials, it is simply db for the host, the user, the password and the database.
  • And that’s it – you are set with a local Shopware 6 installation!

Storefront Watcher

Some extra notes for using the storefront watcher:

  • It does not work using https – so use http instead of https in the .ddev/config.yaml, in .env, and in the storefront url.
  • The file-change triggered automatic browser reload does not work with nginx (at least not out of the box) – so chose apache-fpm as the webserver type.
  • Add a file docker-compose.storefront-watcher.yaml to your .ddev folder
# .ddev/docker-compose.storefront-watcher.yaml
version: "3.6"

services:
  web:
    expose:
      - 9998
      - 9999
    environment:
      - STOREFRONT_PROXY_PORT=9998
      - ESLINT_DISABLE=true
      - 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

A more comprehensive and excellent guide on how to setup ddev for Shopware 6 can be found here: Installing / Developing Shopware 6 with ddev

Leave a Reply

Your email address will not be published.