Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

Stream Loader

1.0 version
Maintained

Stream Loader

The StreamLoader allows you to load images using PHP Streams.

Configuration

1
2
3
4
5
liip_imagine:
    loaders:
        stream.profile_photos:
            stream:
                wrapper: gaufrette://profile_photos

Custom

The Liip\ImagineBundle\Binary\Loader\StreamLoader allows to read images from any stream (http, ftp, and others…) registered thus allowing you to serve your images from literally anywhere.

The example service definition shows how to use a stream wrapped by the Gaufrette filesystem abstraction layer. In order to have this example working, you need to register the stream wrapper first, refer to the Gaufrette README on how to do this.

If you are using the KnpGaufretteBundle you can make use of the StreamWrapper configuration to register the filesystems.

1
2
3
4
5
6
7
8
9
# app/config/services.yml

services:
    acme.liip_imagine.binary.loader.stream.profile_photos:
        class: "%liip_imagine.binary.loader.stream.class%"
        arguments:
            - 'gaufrette://profile_photos/'
        tags:
            - { name: 'liip_imagine.binary.loader', loader: 'stream.profile_photos' }

Usage

Now you are ready to use the AwsS3Resolver by configuring the bundle. The following example will configure the resolver as default.

1
2
3
4
# app/config/config.yml

liip_imagine:
    data_loader: stream.profile_photos

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.