symfony / symfony-docs

The Symfony documentation
https://symfony.com/doc
Other
2.18k stars 5.12k forks source link

[AssetMapper] Allowing for files to be written to some non-local location #19069

Closed fabpot closed 9 months ago

fabpot commented 1 year ago
Q A
Feature PR symfony/symfony#51847
PR author(s) @weaverryan
Merged in 6.4

We created this issue to not forget to document this new feature. We would really appreciate if you can help us with this task. If you are not sure how to do it, please ask us and we will help you.

To fix this issue, please create a PR against the 6.4 branch in the symfony-docs repository.

Thank you! :smiley:

weaverryan commented 1 year ago

This is pretty technical. At MOST it deserves a quick mention. Or maybe no mention at all.

When you run asset-map:compile, it copies all of your assets to a public/assets directory. With this PR, you could create your own class that implements PublicAssetsFilesystemInterface, set its id (or an alias) to asset_mapper.local_public_assets_filesystem (to replace the core) so that you can write your files to some other system - e.g. upload them to S3.

More broadly, it may be worth it to give some guidelines in general on how to use with a CDN. I'd recommend people do nothing and put CloudFlare in front of their app and get an automatic CDN. However, if you want to write your files somewhere else, you can use this strategy.