Skip to content

Commit a6e2875

Browse files
committed
minor #13255 [Asset] Document remote JSON manifest (GromNaN)
This PR was squashed before being merged into the master branch. Discussion ---------- [Asset] Document remote JSON manifest Documentation for symfony/symfony#35762 - New feature for Asset component - Integration in FrameworkBundle configuration Commits ------- be4760c [Asset] Document remote JSON manifest
2 parents 89b6013 + be4760c commit a6e2875

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

components/asset.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@ In those cases, use the
165165
echo $package->getUrl('css/app.css');
166166
// result: build/css/app.b916426ea1d10021f3f17ce8031f93c2.css
167167

168+
If your JSON file is not on your local filesystem but is accessible over HTTP,
169+
you can use the ...
170+
:class:`Symfony\\Component\\Asset\\VersionStrategy\\RemoteJsonManifestVersionStrategy`
171+
with the :doc:`HttpClient component </components/http_client>`::
172+
173+
use Symfony\Component\Asset\Package;
174+
use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy;
175+
use Symfony\Component\HttpClient\HttpClient;
176+
177+
$httpClient = HttpClient::create();
178+
$manifestUrl = 'https://cdn.example.com/rev-manifest.json';
179+
$package = new Package(new RemoteJsonManifestVersionStrategy($manifestUrl, $httpClient));
180+
181+
168182
Custom Version Strategies
169183
.........................
170184

reference/configuration/framework.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,10 @@ package:
20152015
If you request an asset that is *not found* in the ``manifest.json`` file, the original -
20162016
*unmodified* - asset path will be returned.
20172017

2018+
.. note::
2019+
2020+
If an URL is set, the JSON manifest is downloaded on each request using the `http_client`_.
2021+
20182022
translator
20192023
~~~~~~~~~~
20202024

0 commit comments

Comments
 (0)