以下https://developer.shopware.com/docs/guides/hosting/infrastruct/filesystem.html我配置了一个AWS S3存储桶来与我的shopware6安装一起使用,如下所示
shopware:
filesystem:
public:
url: "https://%env(AWS_BUCKET)%.s3.eu-central-1.amazonaws.com/"
type: "amazon-s3"
config:
bucket: "%env(AWS_BUCKET)%"
region: "%env(AWS_REGION)%"
endpoint: "%env(AWS_BUCKET_ENDPOINT)%"
credentials:
key: "%env(AWS_ACCESS_KEY)%"
secret: "%env(AWS_ACCESS_SECRET)%"
root: ""
options:
visibility: "public"
theme:
url: "https://%env(AWS_BUCKET)%.s3.eu-central-1.amazonaws.com/"
type: "amazon-s3"
config:
bucket: "%env(AWS_BUCKET)%"
region: "%env(AWS_REGION)%"
endpoint: "%env(AWS_BUCKET_ENDPOINT)%"
credentials:
key: "%env(AWS_ACCESS_KEY)%"
secret: "%env(AWS_ACCESS_SECRET)%"
root: ""
options:
visibility: "public"
# asset:
# url: "https://%env(AWS_BUCKET)%.s3.eu-central-1.amazonaws.com/"
# type: "amazon-s3"
# config:
# bucket: "%env(AWS_BUCKET)%"
# region: "%env(AWS_REGION)%"
# endpoint: "%env(AWS_BUCKET_ENDPOINT)%"
# credentials:
# key: "%env(AWS_ACCESS_KEY)%"
# secret: "%env(AWS_ACCESS_SECRET)%"
# root: ""
# options:
# visibility: "public"
sitemap:
url: "https://%env(AWS_BUCKET)%.s3.eu-central-1.amazonaws.com/"
type: "amazon-s3"
config:
bucket: "%env(AWS_BUCKET)%"
region: "%env(AWS_REGION)%"
endpoint: "%env(AWS_BUCKET_ENDPOINT)%"
credentials:
key: "%env(AWS_ACCESS_KEY)%"
secret: "%env(AWS_ACCESS_SECRET)%"
root: ""
options:
visibility: "public"
正如你所看到的 - 我注释掉了“资产”部分。预期的行为是,现在捆绑包的文件存储在本地 public/bundles 中。但如果我执行
bin/console assets:install
捆绑包的文件仍然存储在 s3 存储桶中。如果我注释掉“主题”部分,我会注意到同样的不良行为。 为什么?我怎样才能防止这种情况发生? (清除缓存不会改变该行为)
来自 Shopware 文档:
默认情况下,如果没有专门配置,主题、资产和站点地图文件系统的配置将使用
文件系统中的配置。public
因此,当您想测试本地文件系统时,您需要从 Yaml 中删除
public
节点,或者不注释 asset
节点,而是将其设置为类似以下内容:
asset:
url: "https://your.domain/"
type: "local"
config:
root: "%kernel.project_dir%/public"