Open tacman opened 7 months ago
what you describe sounds totally legit and should work, but i don't know if it actually does.
i do not like the naming we have for the concepts in this bundle. i am always confused as to what does what and what can be done. i would have to dig into the code to find out.
i hope that for 3.x we can cleanup the naming and straighten the concepts so it becomes more clear which part does what.
So here's an explanation of how to use s3 for the cached images:
https://symfonycasts.com/screencast/symfony-uploads/cached-s3-filesystem
BUT it's old. It uses OneUpFlysystem, and even has lines like
If you're using version 4 of oneup/flysystem-bundle (so, flysystem v2), the league/flysystem-cached-adapter will not work - it was not updated to support flysystem v2. Someone has created a cached adapter - https://github.com/Lustmored/flysystem-v2-simple-cache-adapter - but configuring it requires extra steps.
I have a working public repo that uses s3 for the original images, but I can't follow this tutorial on how to configure s3 for the cached images.
cleanup the naming and straighten the concepts so it becomes more clear which part does what.
Indeed. I struggle with "cache" and "adapter", and recently removed an extra s3 adapter from a project and couldn't even figure out why I had it. (It didn't support Symfony 7, but evidently my project didn't need it).
I should say that all of my projects using LIIP came from following Ryan's tutorial, which is too outdated to be useful anymore. With version 3 of LIIP, it'd be great to have clearer instructions.
I dug up an old project that used s3 for both the original images and for the cache.
However, it was based on oneup, the cached_uploads_filesystem filesystem. Anyone know how to implement this using phpleague/flysystem-bundle?
# Read the documentation: https://github.com/1up-lab/OneupFlysystemBundle/tree/master/Resources/doc/index.md
oneup_flysystem:
cache:
psr6_app_cache:
psr6:
service: cache.flysystem.psr6
adapters:
uploads_adapter:
awss3v3:
client: Aws\S3\S3Client
bucket: '%env(AWS_S3_BUCKET_NAME)%'
local_uploads_adapter:
local:
directory: "%kernel.project_dir%/public/uploads"
lazy: ~ # boolean (default "false")
writeFlags: ~
linkHandling: ~
permissions: ~
filesystems:
uploads_filesystem:
adapter: uploads_adapter # s'%env(UPLOADS_ADAPTER)%'
cached_uploads_filesystem:
adapter: uploads_adapter
cache: psr6_app_cache
I'm deploying an application to a readonly system (dokku/heroku and others). I've moved my source images to s3, and the cached images are working as expected locally.
Usually my next step is to attach persistent storage and map /public/media/cache to a path on the persistent storage, but it got me wondering if it was possible to configure the cache itself to be remote. Perhaps this is what the cache resolver is for, is there an example that uses something beside the local filesystem for serving the thumbnail images?
In the end, since S3 charges for transfer, it might be too expensive. But when deploying a small site, it might be easier than dealing with persistent storage.