# Shopware reference

Reference for running Shopware 6 on TurboStack: where the files live, the command-line tool, and the scheduled jobs. For setup see [Deploy Shopware on TurboStack](deploy.md); for tuning see [Shopware best practices](best-practices.md).

## File layout

Everything lives under your system user's home directory. `~` is that home directory (for example `/var/www/prod/`). The base directory is `~/shopware/`, which can be symlinked for release-based deployments.

| Path | What it is |
| --- | --- |
| `~/public_html` | Web document root; must point to `~/shopware/public/` (direct or via symlink) |
| `~/shopware/` | Shopware base directory; run the command-line tool from here |
| `~/shopware/public/` | Served files, including the `index.php` front controller |
| `~/shopware/vendor/` | Composer dependencies |
| `~/shopware/custom/` | Plugins and themes |
| `~/shopware/config/` | Configuration: `.env`, `packages/` and `services.yaml` |
| `~/shopware/var/log/` | Logs |

For ownership and permissions, see [Application file layout and permissions](../index.md#file-layout-and-permissions).

## Command-line reference

Shopware ships a command-line interface (CLI) at `bin/console`. Run every command from the Shopware base directory `~/shopware/`. The common commands are below.

| Command | What it does |
| --- | --- |
| `cache:clear` | Clear the application cache |
| `cache:warmup` | Warm the cache after a deploy |
| `dal:refresh:index` | Rebuild the Data Abstraction Layer (DAL) index |
| `es:index` | Build the Elasticsearch or OpenSearch index |
| `media:generate-thumbnails` | Generate media thumbnails |
| `scheduled-task:run` | Run due scheduled tasks |
| `messenger:consume` | Process the message queue |
| `system:update:finish` | Finish an update |

To clear all caches, run the application cache and the shared caches together:

```bash
cd ~/shopware && bin/console cache:clear
tscli redis clear
tscli varnish clear
```

`tscli redis clear` and `tscli varnish clear` use the [TurboStack CLI](../../api/cli.md).

To update Shopware, update the dependencies and then finish the update:

```bash
cd ~/shopware && composer update && bin/console system:update:finish
```

## Cron and background workers

Shopware needs its scheduled tasks run regularly. Add a cron entry for your system user - for example every 5 minutes:

```bash
*/5 * * * * cd ~/shopware && bin/console scheduled-task:run >> ~/logs/scheduled-task.log 2>&1
```

The message queue is processed with `bin/console messenger:consume`. On a busy store, run the consumer as a persistent user system service so it restarts on failure. See [How to manage user system services](../../technologies/system-services/manage-user-services.md).

## Cart storage in Redis (optional)

By default Shopware stores the cart in the database. On a high-traffic store you can move the cart to Redis to reduce database writes during checkout. Point it at the persistent Redis instance (port `6378`) so carts are not lost when the cache is flushed, and give it its own database index. The configuration key changed in Shopware 6.6.8.0.

On Shopware 6.6.8.0 and later, define a named connection and point the cart storage at it in `config/packages/shopware.yaml`:

```yaml
shopware:
    redis:
        connections:
            persistent:
                dsn: 'redis://localhost:6378/3'
    cart:
        storage:
            type: 'redis'
            config:
                connection: 'persistent'
```

On Shopware 6.5 and early 6.6 releases, use the single `redis_url` key instead:

```yaml
shopware:
    cart:
        redis_url: 'redis://localhost:6378/3'
```

Cart lifetime is controlled by `shopware.cart.expire_days` (default `120`). After switching the storage backend, migrate existing carts out of the database:

```bash
bin/console cart:migrate sql
```

## Related

- [Deploy Shopware on TurboStack](deploy.md)
- [Shopware best practices](best-practices.md)
- [Troubleshooting Shopware](troubleshooting.md)
- [Application file layout and permissions](../index.md#file-layout-and-permissions)
- [How to manage user system services](../../technologies/system-services/manage-user-services.md)
