diff --git a/components/asset.rst b/components/asset.rst index a01a0d3a440..730e0557f5d 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -165,6 +165,20 @@ In those cases, use the echo $package->getUrl('css/app.css'); // result: build/css/app.b916426ea1d10021f3f17ce8031f93c2.css +If your JSON file is not on your local filesystem but is accessible over HTTP, +you can use the ... +:class:`Symfony\\Component\\Asset\\VersionStrategy\\RemoteJsonManifestVersionStrategy` +with the :doc:`HttpClient component `:: + + use Symfony\Component\Asset\Package; + use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy; + use Symfony\Component\HttpClient\HttpClient; + + $httpClient = HttpClient::create(); + $manifestUrl = 'https://cdn.example.com/rev-manifest.json'; + $package = new Package(new RemoteJsonManifestVersionStrategy($manifestUrl, $httpClient)); + + Custom Version Strategies ......................... diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index cdef342a55a..26d5ec73f27 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1970,6 +1970,10 @@ package: If you request an asset that is *not found* in the ``manifest.json`` file, the original - *unmodified* - asset path will be returned. +.. note:: + + If an URL is set, the JSON manifest is downloaded on each request using the `http_client`_. + translator ~~~~~~~~~~