@@ -1798,6 +1798,7 @@ Each package can configure the following options:
17981798* :ref: `version <reference-framework-assets-version >`
17991799* :ref: `version_format <reference-assets-version-format >`
18001800* :ref: `json_manifest_path <reference-assets-json-manifest-path >`
1801+ * :ref: `strict_mode <reference-assets-strict-mode >`
18011802
18021803.. _reference-framework-assets-version :
18031804.. _ref-framework-assets-version :
@@ -2041,6 +2042,8 @@ package:
20412042 foo_package :
20422043 # this package uses its own manifest (the default file is ignored)
20432044 json_manifest_path : " %kernel.project_dir%/public/build/a_different_manifest.json"
2045+ # Throws an exception when an asset is not found in the manifest
2046+ strict_mode : %kernel.debug%
20442047 bar_package :
20452048 # this package uses the global manifest (the default file is used)
20462049 base_path : ' /images'
@@ -2061,9 +2064,10 @@ package:
20612064 <!-- you can use absolute URLs too and Symfony will download them automatically -->
20622065 <!-- <framework:assets json-manifest-path="https://cdn.example.com/manifest.json"> -->
20632066 <!-- this package uses its own manifest (the default file is ignored) -->
2067+ <!-- Throws an exception when an asset is not found in the manifest -->
20642068 <framework : package
20652069 name =" foo_package"
2066- json-manifest-path =" %kernel.project_dir%/public/build/a_different_manifest.json" />
2070+ json-manifest-path =" %kernel.project_dir%/public/build/a_different_manifest.json" strict-mode = " %kernel.debug% " />
20672071 <!-- this package uses the global manifest (the default file is used) -->
20682072 <framework : package
20692073 name =" bar_package"
@@ -2087,7 +2091,9 @@ package:
20872091 // 'json_manifest_path' => 'https://cdn.example.com/manifest.json',
20882092 $framework->assets()->package('foo_package')
20892093 // this package uses its own manifest (the default file is ignored)
2090- ->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json');
2094+ ->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json')
2095+ // Throws an exception when an asset is not found in the manifest
2096+ ->setStrictMode('%kernel.debug%');
20912097
20922098 $framework->assets()->package('bar_package')
20932099 // this package uses the global manifest (the default file is used)
@@ -2104,11 +2110,27 @@ package:
21042110
21052111 If you request an asset that is *not found * in the ``manifest.json `` file, the original -
21062112 *unmodified * - asset path will be returned.
2113+ Since Symfony 5.4, you can set ``strict_mode `` to ``true `` to get an exception when an asset is *not found *.
21072114
21082115.. note ::
21092116
21102117 If an URL is set, the JSON manifest is downloaded on each request using the `http_client `_.
21112118
2119+ .. _reference-assets-strict-mode :
2120+
2121+ strict_mode
2122+ ...........
2123+
2124+ **type **: ``boolean `` **default **: ``false ``
2125+
2126+ .. versionadded :: 5.4
2127+
2128+ The ``strict_mode `` option was introduced in Symfony 5.4.
2129+
2130+ When enabled, the strict mode asserts that all requested assets are in the
2131+ manifest file. This option is useful to detect typos or missing assets, the
2132+ recommended value is ``%kernel.debug% ``.
2133+
21122134translator
21132135~~~~~~~~~~
21142136
0 commit comments