Filesystem

Overview

Shopware 6 stores and processes a wide variety of files. This goes from product images or videos to generated documents such as invoices or delivery notes. This data should be stored securely and backups should be generated regularly. Therefore, it is advisable to set up an external storage, which scales with the size of the data, is redundant and performs backups. In addition, for cluster setups with multiple setups, it is necessary to share the files via external storage so that each app server can access the corresponding data.

Flysystem overview

Shopware 6 can be used with several cloud storage providers, it uses Flysystem to provide a common interface between different providers as well as the local filesystem. This enables your shops to read and write files through a common interface.
The filesystem can be divided into multiple adapters. Each adapter can handle one or more of the following directories: media. sitemaps, and more. Of course, you can also use the same configuration for each and all of them:
    One for private files: invoices, delivery notes, plugin files, etc
    One for public files: product pictures, media files, plugin files in general
    One for theme files
    One for sitemap files
    One for bundle assets files

Configuration

The configuration for file storage of Shopware 6 resides in the general bundle configuration:
1
<development root>
2
└── config
3
└── packages
4
└── shopware.yml
Copied!
To set up a non default filesystem for your shop you need to add the filesystem: map to the shopware.yml. Under this key you can separately define your storage for the public, private, theme, sitemap and asset (bundle assets).
1
shopware:
2
filesystem:
3
public:
4
url: "{url-to-your-public-files}"
5
# The Adapter Configuration
6
private:
7
visibility: "private"
8
# The Adapter Configuration
9
theme:
10
url: "{url-to-your-theme-files}"
11
# The Adapter Configuration
12
asset:
13
url: "{url-to-your-asset-files}"
14
# The Adapter Configuration
15
sitemap:
16
url: "{url-to-your-sitemap-files}"
17
# The Adapter Configuration
Copied!

Integrated Adapter Configurations

Local

1
shopware:
2
filesystem:
3
{ADAPTER_NAME}:
4
type: "local"
5
config:
6
root: "%kernel.project_dir%/public"
Copied!

Amazon S3

1
shopware:
2
filesystem:
3
{ADAPTER_NAME}:
4
type: "amazon-s3"
5
visibility: "private" # Default is "public", can be set only on shopware.filesystem.private
6
config:
7
bucket: "{your-public-bucket-name}"
8
region: "{your-bucket-region}"
9
endpoint: "{your-s3-provider-endpoint}"
10
root: "{your-root-folder}"
Copied!
For the usage of Minio, consider setting use_path_style_endpoint to true.

Google Cloud Platform

1
shopware:
2
filesystem:
3
{ADAPTER_NAME}:
4
type: "google-storage"
5
visibility: "private" # Default is "public", can be set only on shopware.filesystem.private
6
config:
7
bucket: "{your-public-bucket-name}"
8
projectId: "{your-project-id}"
9
keyFilePath: "{path-to-your-keyfile}"
Copied!

Add your own adapter

To create an own adapter checkout the official Flysystem guide for that here.
To make your adapter available in Shopware you will need to create a AdapterFactory for your Flysystem provided adapter. An example for that could look like this:
1
<?php
2
​
3
use Shopware\Core\Framework\Adapter\Filesystem\Adapter\AdapterFactoryInterface;
4
use League\Flysystem\AdapterInterface;
5
​
6
class MyFlysystemAdapterFactory implements AdapterFactoryInterface
7
{
8
public function getType(): string
9
{
10
return 'my-adapter-prefix'; // This must match with the type in the yaml file
11
}
12
​
13
public function create(array $config): AdapterInterface
14
{
15
// $config contains the given config from the yaml
16
return new MyFlysystemAdapter($config);
17
}
18
}
Copied!
This new class needs to be registered in the DI with the tag shopware.filesystem.factory to be usable.
Last modified 15h ago