Liipimaginebundle: Flysystem v2 error Argument #1 ($flysystem) must be of type League\Flysystem\FilesystemInterface, League\Flysystem\Filesystem given

Created on 21 Mar 2021  路  6Comments  路  Source: liip/LiipImagineBundle

  1. symfony 5.3 & php 8 with imagick 7
  2. install "league/flysystem-bundle": "^2.0", or "oneup/flysystem-bundle": "^4.0",
  3. install "liip/imagine-bundle": "^2.5",

Steps to reproduce

I tried it first with oneup/flysystem-bundle then i removed it and installed league/flysystem-bundle so i'm gonna paste it's config:

flysystem.yaml

flysystem:
    storages:
        default.storage:
            adapter: 'local'
            options:
                directory: '%app.upload_dir%'

liip_imagine.yaml

# See dos how to configure the bundle: https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html
liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    driver: "imagick"

    loaders:
        flysystem_loader:
            flysystem:
                filesystem_service: default.storage
    # default loader to use for all filter sets
    data_loader: flysystem_loader

    resolvers:
        flysystem_resolver:
            flysystem:
                filesystem_service: default.storage
                cache_prefix: media/cache
                root_url: '%app.upload_dir%'
    #default cache resolver for saving thumbnails
    cache: flysystem_resolver

    filter_sets:
        # the name of the "filter set"
        my_thumb:

            # adjust the image quality to 75%
            quality: 75

            # list of transformations to apply (the "filters")
            filters:

                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail: { size: [ 120, 90 ], mode: outbound }

                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                background: { size: [ 124, 94 ], position: center, color: '#000000' }

And in my service i simply inject it in a normal way, as per Flysystem-bundle docs

Expected result

I haven't tested the liip bundle with the flysystem loader/resolver because i can't even clear the cache with the new config.

Actual result

 Liip\ImagineBundle\Imagine\Cache\Resolver\FlysystemResolver::__construct(): Argument #1 ($flysystem) must be of type League\Flysystem\FilesystemInterface, League\Flysystem\Filesystem given, called in /  
  var/www/erp/var/cache/dev/ContainerTKhxmjs/App_KernelDevDebugContainer.php on line 1323

Most helpful comment

All good with the 2.x-dev, i haven't tested the liip features yet but at least the above configuration works. Thank you

All 6 comments

I've got the exact same issue !
Here is my configuration:

* oneup_flysystem CONFIG*

oneup_flysystem:
    adapters:
        public_uploads_adapter:
            local:
                location: '%kernel.project_dir%/public/%uploads_dir_name%'

        private_uploads_adapter:
            local:
                location: '%kernel.project_dir%/storage/uploads'

    filesystems:
        public_uploads_filesystem:
            adapter: public_uploads_adapter

        private_uploads_filesystem:
            adapter: private_uploads_adapter

* liip_imagine CONFIG*

liip_imagine:
        flysystem_loader:
            flysystem:
                filesystem_service: oneup_flysystem.public_uploads_filesystem_filesystem
        data_loader: flysystem_loader

    resolvers:
        flysystem_resolver:
            flysystem:
                filesystem_service: oneup_flysystem.public_uploads_filesystem_filesystem
                cache_prefix: media/cache
                root_url: '/uploads'

    cache: flysystem_resolver

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

        squared_thumbnail_medium:
            filters:
                thumbnail:
                    size:          [500, 500]
                    mode:          outbound
                    allow_upscale: true

Hello,

What version of LiipImagineBundle are you using?

From your error it seems like it still trying to use FlysystemResolver (v1), not FlysystemV2Resolver (v2).

For me using composer req liip/imagine-bundle:^2.x-dev does the trick, since there isn't a new release to contain the new flysystem v2 related changes.

"liip/imagine-bundle": "^2.5", is what i'm using. I'll try with the 2.x-dev tonight and return with an updated answer, thank you.

@lebadapetru ok.

All good with the 2.x-dev, i haven't tested the liip features yet but at least the above configuration works. Thank you

No problem. Let's hope for a new stable release in the near future. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aerendir picture Aerendir  路  3Comments

chiqui3d picture chiqui3d  路  3Comments

fabianbartsch picture fabianbartsch  路  3Comments

weyandch picture weyandch  路  5Comments

robfrawley picture robfrawley  路  4Comments