Skip to content

[Asset] Document remote JSON manifest #13255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Asset] Document remote JSON manifest
  • Loading branch information
GromNaN authored and javiereguiluz committed Apr 17, 2020
commit be4760c72c591fa698218f8c85bb4c61e570819b
14 changes: 14 additions & 0 deletions components/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 </components/http_client>`::

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
.........................

Expand Down
4 changes: 4 additions & 0 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~

Expand Down