OrderAndChaos
OrderAndChaos

Reputation: 3860

Configuring LiipImagineBundle Symfony to work with Flysystem

I've been trying to configure a CDN (S3) to work with LiipImagineBundle, but keep getting stuck when it is asking for a non-existent service.

What does this mean?

The value of the filesystem_service property must be a service that returns an instance of League\Flysystem\Filesystem.

From here: http://symfony.com/doc/current/bundles/LiipImagineBundle/cache-resolver/flysystem.html

and here: http://symfony.com/doc/current/bundles/LiipImagineBundle/data-loader/flysystem.html

I have tried to create a service that returns an instance of League\Flysystem\Filesystem as follows:

league.flysystem.s3adaptor:
    class: League\Flysystem\AwsS3v3\AwsS3Adapter
    arguments: ['@acme.s3_client', '%amazon.s3.bucket%', 's3_fs', '@?']

league.flysystem.filesystem:
    class: League\Flysystem\Filesystem
    arguments: ['@league.flysystem.s3adaptor', '@?']
    calls:
        - [addPlugin, ['@oneup_flysystem.plugin.list_with']]

I'm not sure if this is along the right lines or not, but I can't get this working.

Any help or advice will be greatly appreciated.

Upvotes: 3

Views: 791

Answers (1)

OrderAndChaos
OrderAndChaos

Reputation: 3860

I was on the right lines, I had just misconfigured my LiipImagineBundle slightly.

To return an instance of League\Flysystem\Filesystem you first need to create a service for the adaptor that you want to use, in this case league.flysystem.s3adaptor does this. Then pass that as an argument to league.flysystem.filesystem.

league.flysystem.s3adaptor:
    class: League\Flysystem\AwsS3v3\AwsS3Adapter
    arguments: ['@acme.s3_client', '%amazon.s3.bucket%']

league.flysystem.filesystem:
    class: League\Flysystem\Filesystem
    arguments: ['@league.flysystem.s3adaptor']
    calls:
        - [addPlugin, ['@oneup_flysystem.plugin.list_with']]

LiipImagineBundle config:

liip_imagine:
    resolvers:
            profile_photos:
                flysystem:
                    filesystem_service: league.flysystem.filesystem
                    root_url:           "https://s3.eu-west-2.amazonaws.com/nameofthebucket/"
                    cache_prefix:       media/cache
                    visibility:         public
    loaders:
        profile_photos:
            flysystem:
                filesystem_service: league.flysystem.filesystem
    data_loader: profile_photos
    cache: profile_photos

Upvotes: 5

Related Questions