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
相关产品推荐
相关产品推荐

