Hello,
While I was trying to implement prodct's images storage over S3, I had several big headscratch, the worst of them beeing this :
# vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/Resources/config/app/config.yml
#...
liip_imagine:
loaders:
default:
filesystem:
data_root: "%kernel.root_dir%/../web/media/image"
#...
you define a default loader using the filesystem, and because I load my conf. this way :
# app/config/config.yml
#...
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
#...
- { resource: "knp_gaufrette.yml"}
- { resource: "liip_imagine.yml"}
your values prevented me from defining my own default loader.
my workaround is to define it in a fiule loaded before yours (because I don't know if I can safely load all mine before yours)
# app/config/config.yml
- { resource: "liip_imagine_called_before_sylius_core_break_it_all.yml"} # work in combination with `liip_imagine.yml` it define some values before sylius core do it and prevent the standard file to define the corect ones
#...
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
#...
- { resource: "knp_gaufrette.yml"}
- { resource: "liip_imagine.yml"}
OFF topic : By the way, it took me a loong time to have S3 working on my install, I recommend you to write a doc. about it, because it's hard to find that you use predefined gaufrette filesystem and that wee need to redefine them in order to have sylius write elsewhere automatically.
something like this :
knp_gaufrette:
stream_wrapper: ~
adapters:
sylius_image:
aws_s3:
service_id: app_amazonS3
bucket_name: "%aws.s3_client.bucketName%"
options:
directory: someArbitraryPathTo/whateverYouWant
create: true
filesystems:
sylius_image:
adapter: "sylius_image"
liip_imagine:
# role : where to find the raw image that need computing
loaders:
default:
stream:
wrapper: "gaufrette://sylius_image/"
@bruno-ds Hi, I've been trying for hours now to make sylius works with Aws s3 , I keep getting different type of error , can you please check my question here and help me with the config you have used to make it works.
Thank you
@aimeric : It seem to be more an AWS related error, see : http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-retrieval
PS : knowing this, maybe you should consider going to stackoverflow or sylius' slack , an issue tracker is not the best suited tool for this problem.
@bruno-ds , I fix the first error by creating a file with the environment variable. but now I'm have the following error :
An exception has been thrown during the rendering of a template ("Found 1 error while validating the input provided for the HeadObject operation:
[Bucket] must be a string or an object that implements __toString(). Found bool(false)").
_horizontalList_home.html.twig (line 46):
{% set path = product.imagesByType('thumbnail').first.path|imagine_filter(filter|default('sylius_shop_product_latest_product_thumbnail')) %}
I have asked a question on stackoverflow but I didn't get any response.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.
I suppose this is still a valid feedback
I guess the issue with liip_imagine configuration should be reported to their issue tracker, if you define two default loaders in two different files, the last one defined should win.
Hi. Does anyone know the solution? Currently I am having the same problem and I do not know how to solve it. It's impossible to configure Sylius / liip_imagine with aws s3.
Hello @calambrenet did you try to follow my advices?
My sylius install run fine with both liip_imagine and aws s3 as you can find here :
https://store.itophub.io/en_US/
https://itophub-production-s3itophubpublic-1kewhmft2hx3g.s3.eu-west-3.amazonaws.com/sylius_shop_product_thumbnail/9b/fc/67dafd4516f7e00cd6f5fc1fc81e.jpeg
@bruno-ds How do you do it? XD I'm going to go crazy trying to make it work. I managed to get knp_gaufrette to save the images in s3 but liip_imagine does not read the images from there but from the local filesystem. This is my configuration:
services.yml
app.amazon_s3:
class: Aws\S3\S3Client
factory: [ Aws\S3\S3Client , factory]
arguments:
-
region: "%amazon_s3.region%"
version: "%amazon_s3.version%"
credentials:
key: "%amazon_s3.key%"
secret: "%amazon_s3.secret%"
sylius.image_uploader:
class: Sylius\Component\Core\Uploader\ImageUploader
arguments: [ "@app.sylius.image_uploader.config" ]
app.sylius.image_uploader.config:
class: 'Gaufrette\Filesystem'
factory: [ "@knp_gaufrette.filesystem_map", get ]
arguments: [ 'sylius_image' ]
app.imagine.cache.resolver.amazon_s3:
class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
arguments:
- "@app.amazon_s3"
- "%amazon_s3.bucket%"
tags:
- { name: "liip_imagine.cache.resolver", resolver: "amazon_s3" }
calls:
- [setCachePrefix, ["cache"]]
config.yml
knp_gaufrette:
stream_wrapper: ~
adapters:
sylius_image:
aws_s3:
service_id: app.amazon_s3
bucket_name: "%amazon_s3.bucket%"
options:
directory: 'images'
filesystems:
sylius_image:
adapter: "%sylius.uploader.filesystem%"
stream_wrapper: ~
liip_imagine:
loaders:
sylius_image:
stream:
wrapper: gaufrette://sylius_image/
default:
filesystem:
data_root: "%kernel.root_dir%/../web/media/image_test"
data_loader: sylius_image
cache: amazon_s3
resolvers:
amazon_s3:
aws_s3:
client_config:
credentials:
key: "%amazon_s3.key%"
secret: "%amazon_s3.secret%"
region: "%amazon_s3.region%"
version: "%amazon_s3.version%"
bucket: "%amazon_s3.bucket%"
get_options:
Scheme: https
put_options:
CacheControl: "max-age=86400"
filter_sets :
sylius_shop_product_original: ~
sylius_shop_product_tiny_thumbnail:
data_loader: sylius_image
filters:
thumbnail: { size: [64, 64], mode: outbound }
sylius_shop_product_small_thumbnail:
data_loader: sylius_image
filters:
thumbnail: { size: [150, 112], mode: outbound }
sylius_shop_product_thumbnail:
data_loader: sylius_image
filters:
thuimbnail: { size: [260, 260], mode: outbound }
sylius_shop_product_large_thumbnail:
data_loader: sylius_image
filters:
thumbnail: { size: [550, 412], mode: outbound }
sylius_shop_product_latest_product_thumbnail:
data_loader: sylius_image
filters:
thumbnail: { size: [180, 200], mode: outbound }
If I delete the configuration of knp_gaufrette so that the original images are saved in the local filesystem, liip_imagine create the cache in s3. So I think liip_imagine always reads the local filesystem files and ignores my configuration.
you should try the slack or the forum, gitHub issue tracker is not the right tool as we're going to pollute the thread.
so this is my last advice here :
you should make sure that
liip_imagine:
loaders:
default:
stream:
wrapper: "gaufrette://sylius_image/"
is defined before { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
@bruno-ds Thank you very much, I have made it work.
The real issue, to me, is that Sylius should not use the "default" loader. That must be reserved for the app. Sylius could easily use a sylius_image loader.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.
Most helpful comment
The real issue, to me, is that Sylius should not use the "default" loader. That must be reserved for the app. Sylius could easily use a
sylius_imageloader.