---
title: "Local devenv set up - Shopware 6"
description: "This blog post is mainly a reference for myself. So that I don't always have to search for commands and places where I need to change something. Basically..."
url: "https://brocksi.net/blog/local-devenv-set-up-shopware-6/"
author: "Björn Meyer"
published: "2024-01-15"
lang: "en"
categories: ["Shopware 6", "PHP"]
---

# Local devenv set up - Shopware 6

This blog post is mainly a reference for myself. So that I don’t always have to search for commands and places where I need to change something. Basically it shows the steps to set up a new instance with devenv and Shopware 6. It also shows how to enable xdebug if needed. And how to use an SSL certificate and what needs to be changed. I assume that devenv, direnv and cachix are already set up (if not, take a look at this [devenv guide](https://developer.shopware.com/docs/guides/installation/devenv.html "devenv guide")).

## Steps for set up a new Shopware 6 instance

_Tested with devenv (0.6.3) and Shopware 6.4.20.2_

**_Open Terminal 1_**

```
git clone git@github.com:shopware/shopware.git shopware-6-4-20-2
```

```
cd shopware-6-4-20-2
```

```
direnv allow
```

```
git checkout tags/v6.4.20.2 -b v6.4.20.2
```

```
devenv up
```

**_Open Terminal 2_**

```
cd shopware-6-4-20-2
```

```
devenv shell
```

```
composer setup
```

Now check [http://localhost:8000/](http://localhost:8000/ "http://localhost:8000/") and [http://localhost:8000/admin](http://localhost:8000/admin "http://localhost:8000/admin").

**Command to install some demo data** (optional, execute inside devenv shell)

```
APP_ENV=prod bin/console framework:demodata && bin/console dal:refresh:index
```

## Xdebug

Changes needed in **devenv.nix** file of your project

```
extensions = [ "grpc" "xdebug" ];

ini = ''
  ...
  xdebug.mode = "debug"
  xdebug.start_with_request = "trigger"
  xdebug.discover_client_host = 1
  xdebug.var_display_max_depth = -1
  xdebug.var_display_max_data = -1
  xdebug.var_display_max_children = -1
  ...
```

Example command to use Xdebug with CLI inside devenv shell

```
export XDEBUG_MODE=debug XDEBUG_SESSION=1; export XDEBUG_CONFIG="idekey=PHPSTORM"; php bin/console theme:compile
```

## SSL

Create a **devenv.local.nix** file in your project root

```
{ lib, config, ... }: {
  env.APP_URL = "https://localhost";

  certificates = [
    "localhost"
  ];

  services.caddy = {
      virtualHosts."localhost" = {
        extraConfig = ''
          tls .devenv/state/mkcert/localhost.pem .devenv/state/mkcert/localhost-key.pem

          @default {
            not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /sitemap/*
          }

          root * public
          php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} {
              trusted_proxies private_ranges
          }
          file_server
        '';
      };
    };
}
```

If you still have trouble that HTTPS is not working and you are not the root user (and using Linux) try executing this and afterwards restart devenv:

```
sudo sysctl net.ipv4.ip_unprivileged_port_start=80
```

## Alternatives

- [Kellerkinder devenv](https://github.com/kellerkinderDE/devenv-shopware "Kellerkinder devenv")
- [dockware.io](https://dockware.io/ "dockware.io") (Docker)
