You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Symfony6整合Flysystem与LiipImageBundle时触发类型错误求助

问题解决:LiipImagineBundle与Flysystem类型不匹配错误

这不是库的Bug,是配置参数填错导致的。

错误原因:Liip\ImagineBundle\Binary\Loader\FlysystemV2Loader要求传入实现League\Flysystem\FilesystemOperator接口的实例,但你配置里指定的flysystem.adapter.private.storage是底层适配器类(League\Flysystem\Local\LocalFilesystemAdapter),不符合类型要求。Flysystem定义的private.storage才是正确的FilesystemOperator实例。

修改你的liip_imagine配置,将filesystem_service的值改为private.storage:

liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    driver: "imagick"

    loaders:
        flysystem_loader:
            flysystem:
                filesystem_service: private.storage # 修正此处参数
    data_loader: flysystem_loader

    filter_sets:
        my_thumb:
            filters:
                thumbnail:
                    size: [200, 200]
                    mode: outbound
                    allow_upscale: true


############################
flysystem:
    storages:
        private.storage:
            adapter: 'local'
            options:
                directory: '%kernel.project_dir%/var/storage/files'

修改完成后清理缓存:

php bin/console cache:clear

之后再调用filterService->getUrlOfFilteredImage()就不会出现类型错误了。

内容的提问来源于stack exchange,提问作者ciastekkkk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 17:39:33